Interactions with RSK
After having configured the RSK node, we can then manage it as a service that can be started with the following:
sudo service rsk start
As a result, RSK will run as a daemon in the background and download the blockchain (a few GBs) in the /var/lib/rsk/database/testnet directory. Similarly, you can stop, restart, or check the situation of the service using the following:
sudo service rsk restart
sudo service rsk stop
service rsk status
The RSK project provides a useful console that enables interaction with an RSK node through RPC calls. We can install this utility using npm:
git clone https://github.com/rsksmart/utilities.git
cd utilities/console && npm install
After the installation is complete, open a new CLI and run the following command to access the console (by default, the RSK node runs in port 4444):
node console.js -server localhost:4444
This will open for you an interactive console that allows you to send commands to your RSK smart node. You can find a list of available RPC commands in the official documentation (https://github.com/rsksmart/rskj/wiki/JSON-RPC-API-compatibility-matrix).
It is worth mentioning that an RSK node behaves like an Ethereum node by exposing the Web3 API over RPC, whereas the JavaScript console is a wrapper for the web3js API (part of the Ethereum project) to execute Web3 available calls in a bitcoin-related environment. We will cover this API in depth in Chapter 4, Peer-to-Peer Auctions in Ethereum, Chapter 5, Tontine Game with Truffle and Drizzle and Chapter 6, Blockchain-Based Futures System.