Setup node using Java

To setup a Rootstock node using Java, you need to:

For Mac M1 / M2 (Apple Chips) using x86 based software:

  • Ensure you have Rosetta installed. This is typically pre-installed on recent macOS versions.
  • Download an x86 JDK build, such as Azul Zulu 11 (x86), to ensure compatibility with x86 based software.

Install the node using a JAR file

  • Download and Setup
    1. Download the JAR: Download the Fat JAR or Uber JAR from RSKj releases, or compile it reproducibly or otherwise.
    2. Create Directory: Create a directory for the node.
      mkdir rskj-node-jar
      cd ~/rskj-node-jar
    3. Move the JAR: Move or copy the just downloaded jar file to your directory.
      mv ~/Downloads/rskj-core-5.4.0-FINGERROOT-all.jar SHA256SUMS.asc /Users/{user}/rskj-node-jar/
  • Configuration
    1. Create Config Directory: Create another directory inside ~/rskj-node-jar/config
      mkdir config
    2. Download Config File: Get node.conf from here.
    3. Move Config File: Move the node.conf file to the config directory.
  • Run the Node
    • Linux, Mac OSX
      java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start
    • Windows
      java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start

      Replace <PATH-TO-THE-RSKJ-JAR> with the actual path to your JAR file. For example, C:/RskjCode/rskj-core-6.0.0-ARROWHEAD-all.jar.

Using Import Sync

Instead of the default synchronization, you can use import sync to import a pre-synchronized database from a trusted origin, which is significantly faster.

  • Running node with Import Sync
    • Linux, Mac OSX
      java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
    • Windows
      java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
  • Resolving memory issues
    • Memory Issues? If you encounter memory errors and meet the minimum hardware requirements, consider using -Xmx4G flag to allocate more memory as shown below:
    • Linux, Mac OSX
      $ java -Xmx4G -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
    • Windows
      C:\> java -Xmx4G -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import

      Replace <PATH-TO-THE-RSKJ-JAR> with your JAR file path. For configuration details, see database.import setting.

Check the RPC

After starting the node, if there's no output, it's running correctly.

  1. To confirm, open a new console tab (it is important you do not close this tab or interrupt the process) and test the node's RPC server. A sample cURL request:

    • Linux, Mac OSX

      curl http://localhost:4444 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'
    • Windows

      curl http://localhost:4444 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'

      Expect a response like:

      {"jsonrpc":"2.0","id":67,"result":"RskJ/5.3.0/Mac OS X/Java1.8/ARROWHEAD-202f1c5"}
  2. To check the block number:

    • Linux, Mac OSX

      curl -X POST http://localhost:4444/ -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"eth_blockNumber","params":[],"id":1}'
    • Windows

      curl -X POST http://localhost:4444/ -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"eth_blockNumber","params":[],"id":1}'

      Output:

      {"jsonrpc":"2.0","id":1,"result":"0x0"}

Now, you have successfully setup a Rootstock node using the jar file. The result property represents the latest synced block in hexadecimal.

Switching networks

To change networks on the RSKj node, use the following commands:

  • Mainnet
    java -cp <PATH-TO-THE-RSKJ-FATJAR> co.rsk.Start
  • Testnet
    java -cp <PATH-TO-THE-RSKJ-FATJAR> co.rsk.Start --testnet
  • Regtest
    java -cp <PATH-TO-THE-RSKJ-FATJAR> co.rsk.Start --regtest

Replace <PATH-TO-THE-RSKJ-FATJAR> with the actual path to your jar file. For example: C:/RskjCode/rskj-core-6.0.0-ARROWHEAD-all.jar.

Video walkthrough

Receive updates

Get the latest updates from the Rootstock ecosystem

Loading...