Running RNode (v 0.6.x) with Docker

In this tutorial, you will learn how to

  • install set up and Docker
  • download and set up three RNodes
  • create a simple Hello World contract to deploy on your own local platform

If you have any problems or need help, leave a comment below and we will assist you as much as possible. If you want to learn how to connect to a bootstrap RNode using Amazon AWS, click here.

1. Install docker from: https://www.docker.com/get-docker

Post-installation steps for Linux users:
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
* For the changes to take effect you will need to log-out & log-in
Post-installation notes for Windows users:
1. Make sure docker is on Linux containers mode. You can check it by right clicking on the docker system tray icon. If it says "switch to Windows containers," you are all set. If it says, "switch to Linux containers," click on it. :).
2. Run all commands in elevated PowerShells. To get an elevated PowerShell: Right click on the PowerShell icon and click on the `Run as Administrator` option.

2. Create a docker network

$ docker network create rnode-net

3. Download RNode

$ docker pull rchain/rnode:latest

4. Create directories for three nodes and download our dummy validator bonds file.

$ mkdir -p $HOME/var/rnode0/genesis/
$ curl https://repo.pyr8.io/rnode-test-sessions/bonds.txt -o $HOME/var/rnode0/genesis/bonds.txt
$ mkdir -p $HOME/var/rnode1/
$ mkdir -p $HOME/var/rnode2/

5. Start a bootstrap node:

$ docker run -it --rm --network rnode-net --name rnode0 -v $HOME/var/rnode0:/var/lib/rnode rchain/rnode:latest run --validator-private-key 97b4fb2f783af685ef25cf150e63f41be7f46d32ddb7258a2edd092dcc4dfd75 -s --host
Bootstrap node address annotated in red

6. Start two nodes using the bootstrap node address (for the following commands you will need to replace the bootstrap address with your node’s address):

$ docker run -it --rm --network rnode-net --name rnode1 -v $HOME/var/rnode1:/var/lib/rnode rchain/rnode:latest run --validator-private-key 774149895133833120a34bab83927e34f03f32ed22949f48209de9335953d6c4 --bootstrap rnode://2c208c649ee799a960c2d7688836c1d82ae17c9b@ --host
$ docker run -it --rm --network rnode-net --name rnode2 -v $HOME/var/rnode2:/var/lib/rnode rchain/rnode:latest run --validator-private-key fbf47c835b16a6fcb287f3c620fdf144852407d3ffc8d1c5b337dab3a412501e --bootstrap rnode://2c208c649ee799a960c2d7688836c1d82ae17c9b@ --host

7. Write some rholang code:

$ mkdir $HOME/var/rholang
* macOS & Linux users only:
$ echo 'contract @"HelloWorld"(return) = {return!("Hello, World!")}' > $HOME/var/rholang/hello_world.rho
* Windows users only:
$ echo 'contract @"HelloWorld"(return) = {return!("Hello, World!")}' | sc $HOME/var/rholang/hello_world.rho

8. Deploy a block with the Rholang code:

$ docker run -it --rm --network rnode-net --name rnode-deploy1 -v $HOME/var/rholang:/var/ rchain/rnode:latest --grpc-host rnode1 deploy  --from "0x1" --phlo-limit 0 --phlo-price 0 --nonce 0 /var/hello_world.rho

9. Send the block to the network:

$ docker run -it --rm --network rnode-net --name rnode-propose1 -v $HOME/var/rholang:/var/ rchain/rnode:latest --grpc-host rnode1 propose
rnode2 adds the block we sent via rnode1

10. Use the contract you deployed on rnode1 on any of the other nodes (example uses rnode2):

* macOS & Linux users only:
$ echo 'new chan in { @"HelloWorld"!(*chan) | for (@text <- chan) { @"stdout"!(text) } }' > $HOME/var/rholang/say_hello.rho
* Windows users only:
$ echo 'new chan in { @"HelloWorld"!(*chan) | for (@text <- chan) { @"stdout"!(text) } }' | sc $HOME/var/rholang/say_hello.rho
$ docker run -it --rm --network rnode-net --name rnode-deploy2 -v $HOME/var/rholang:/var/ rchain/rnode:latest --grpc-host rnode2 deploy --from "0x1" --phlo-limit 0 --phlo-price 0 --nonce 0 /var/say_hello.rho
$ docker run -it --rm --network rnode-net --name rnode-propose2 -v $HOME/var/rholang:/var/ rchain/rnode:latest --grpc-host rnode2 propose
Our second block uses the HelloWorld contract we sent on the first block to print “Hello, World!”