RSKj for Developers

Who needs to develop using RSKj?

If you are developing smart contracts, developing DApps, or participating in a hackathon, you are likely to want to iterate fast, and therefore need quicker feedback loops.

Running RSKj in Regtest mode is the best fit for these needs.

Steps

Install Java

  • The RSKj executable is a JAR file, and requires Java to run.
  • Install the Java 8 JDK.

Download RSKj JAR

  • Navigate to RSKj’s releases page
  • From the latest release, download a file whose name looks like rskj-core-*.jar, where * is replaced by the release tag name, for example 3.1.0-IRIS.

Run RSKj

java -cp ${JAR} co.rsk.Start \
  --regtest \
  --reset \
  -Drpc.providers.web.cors=* \
  -Dminer.client.autoMine=true \
  co.rsk.Start
  • The above command runs RSKj connected to Regtest, which is a localhost-only network, clears the database each time the node is started, and enables both CORS and autoMine (which makes it behave similar to ganache).
  • These are the most useful and commonly used flags and options for when you are developing or testing smart contracts and DApps.

Import

Using --import indicates that the block database should be imported from an external source. This is typically expected to be used when connecting to RSK Testnet or RSK Mainnet, and when a reduction in “initial sync time” is desired.

java -cp ${JAR} co.rsk.Start \
  --import \
  --testnet

Note that the --import feature is to be used ONLY for testing and development purposes and not in production.

Advanced

Developer Tools

Debugging

RPC

Remote procedure calls (JSON-RPC) are the primary interface through which RSK nodes communicate over the network.

JSON-RPC is available over two network transport protocols: HTTP and WebSockets

Note that RSK public nodes do not expose WebSockets, they are HTTP only. To work around this, you may either run your own RSK node, or use a third-party node provider, such as Getblock.