Skip to main content
Time to read: 1 min

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.

Video walkthrough

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.

  2. Create Directory: Create a directory for the node.

mkdir rskj-node-jar
cd ~/rskj-node-jar
  1. Move the JAR: Move or copy the just downloaded jar file to your directory.
mv ~/Downloads/rskj-core-6.3.1-ARROWHEAD-all.jar SHA256SUMS.asc /Users/{user}/rskj-node-jar/

Configuration

  1. Create Config Directory: Create another directory inside ~/rskj-node-jar/config
  mkdir config
  1. Download Config File: Get node.conf from here.
  2. Move Config File: Move the node.conf file to the config directory.

Run the Node

java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start
Tip

Replace <PATH-TO-THE-RSKJ-JAR> with the actual path to your JAR file. For example, C:/RskjCode/rskj-core-6.3.1-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.

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:

java -Xmx4G -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
Tip

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

Check the RPC

Info

After starting the node, if there's no output, this means 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:
curl http://localhost:4444 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'

Output:

{"jsonrpc":"2.0","id":67,"result":"RskJ/6.3.1/Mac OS X/Java1.8/ARROWHEAD-202f1c5"}
  1. To check the block number:
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"}
Success

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
Tip

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

Last updated on by Edwin Liava'a