Ir al contenido principal
Time to read: 1 min
Para el índice completo de documentación, consulte llms.txt

Setup node using Java

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

Important

Starting with v6.4.0, the minimum supported Java LTS version is Java 17. Previous Java versions will no longer be supported.

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 17 (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-7.0.0-LOVELL-all.jar SHA256SUMS.asc /Users/{user}/rskj-node-jar/

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-7.0.0-LOVELL-all.jar.

Using Import Sync

Instead of syncing the whole chain from peers, a new node can be bootstrapped from published bootstrap data — a pre-synchronized database, signed by its publishers. RSKj downloads and verifies it for you; there is no file to fetch yourself and no path to pass to the flag.

Import sync erases the database every time it runs

Every time a node starts with import enabled, it deletes its database directory and downloads the bootstrap data again — even if the node was fully synced a minute earlier. Run it as a one-off from the command line, and never leave database.import.enabled = true in a configuration file.

In short:

  1. Check that you are on Java 17 and RSKj VETIVER-9.0.4 or later — earlier versions cannot read the bootstrap data published today.
  2. Make sure you have room for a full node's database, per the minimum requirements, plus about three times the size of the bootstrap archive in temporary space.
  3. Run the node once with --import. RSKj downloads the published bootstrap data, checks that enough trusted signers agree on it, and loads it into a fresh database.
  4. Stop the node and start it again without --import. It continues syncing from the imported height.
  5. Remove the leftover archive and extracted file from the temporary directory.
java -Xmx4G -cp <PATH-TO-THE-RSKJ-JAR> co.rsk.Start --import

Set -Xmx4G on this command. Left out, the JVM sizes the heap from the machine's physical RAM instead, so what the import gets depends on the host rather than on what the import needs — and it runs out only after the download has already finished. If the import still fails with OutOfMemoryError, raise it further.

Tip

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

For the full procedure — checking which height the import will land you on before committing to the download, confirming it worked, cleaning up, and what each failure message means — see Bootstrap a node using Import Sync.

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.6.0/Mac OS X/Java17/SNAPSHOT-95a8f1ab84"}
  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":"0x3710"}
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-7.0.0-LOVELL-all.jar.

Última actualización en por rsk-devx-app[bot]