Setup node using Java
To setup a Rootstock node using Java, you need to:
- Ensure your system meets the minimum requirements for installing the Rootstock node.
- Install Java 8 JDK.
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
- Download the JAR: Download the Fat JAR or Uber JAR from RSKj releases, or compile it reproducibly or otherwise.
- Create Directory: Create a directory for the node.
mkdir rskj-node-jar cd ~/rskj-node-jar
- 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
- Create Config Directory: Create another directory inside
~/rskj-node-jar/config
mkdir config
- Download Config File: Get
node.conf
from here. - Move Config File: Move the
node.conf
file to theconfig
directory.
- Create Config Directory: Create another directory inside
- 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-5.4.0-FINGERROOT-all.jar
.
- Linux, Mac OSX
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
- Linux, Mac OSX
- 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, seedatabase.import
setting.
- Memory Issues? If you encounter memory errors and meet the minimum hardware requirements, consider using
Check the RPC
If you don't get any output after starting the node, then it's running correctly. 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.
- Run sample request
- Run the following 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
You should get a response like this:
curl http://localhost:4444 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'
{"jsonrpc":"2.0","id":67,"result":"RskJ/5.4.0/Mac OS X/Java1.8/FINGERROOT-202f1c5"}
- Linux, Mac OSX
- Run the following sample cURL request:
- Check block number
- 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}'
{"jsonrpc":"2.0","id":1,"result":"0x0"}
- Linux, Mac OSX
- To check the block number:
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-5.4.0-FINGERROOT-all.jar
.