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.
- 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
-
Download the JAR: Download the Fat JAR or Uber JAR from RSKj releases, or compile it reproducibly.
-
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-6.3.1-ARROWHEAD-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.
Run the Node
- Linux, Mac OSX
- Windows
java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start
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.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.
- Linux, Mac OSX
- Windows
java -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
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
- Windows
java -Xmx4G -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import
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, this means 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. A sample cURL request:
- Linux, Mac OSX
- Windows
curl http://localhost:4444 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'
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"}
- To check the block number:
- Linux, Mac OSX
- Windows
curl -X POST http://localhost:4444/ -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"eth_blockNumber","params":[],"id":1}'
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.3.1-ARROWHEAD-all.jar
.