If you’ve heard Greg Meredith speak about his vision for RChain, you know what it’s like to be excited about a blockchain project. If you’ve seen RChain’s design for sharding, you realize that throughput is a solvable problem. If you’ve read about rho calculus, you know the expressivity that comes with concurrent computation. It seems any place you look in the RChain project, there is innovation driving the team.

If you’ve actually tried to code in Rholang, you may have noticed the reference material is sparse. That doesn’t mean it’s difficult, and you don’t have to wait to begin learning how to program for this new blockchain.

I’ll show you how to get your first Rholang program running.

A quick and dirty way to run code

Before I show you how to properly execute your own Rholang code on a stand-alone node, I should mention that members of the RChain community have created a great resource for beginners to test simple programs. Check out rchain.cloud to run your first few Rholang programs without setting up a node environment.

Of course, you’ll quickly graduate to needing your own node for development, but fear not. You can spin up a stand-alone node in no time. Let’s see how.

Running a minimum RNode

Start by downloading the software to install RNode for your platform.

(If you have trouble with the install, try our Docker tutorial.)

Setting up a simple node to run Rholang code is pretty straightforward.

To start a minimal node environment use this command:

$ rnode run --standalone --no-upnp

(–standalone) starts a local node that doesn’t connect to any other nodes, and (–no-upnp) doesn’t try to open your firewall for incoming connections. If all is well, you should see something like this.



The node is now active, but in order to interact with it, we need to open up another terminal.

Open a second terminal window, enter:

$ rnode repl

The repl command allows you to execute any Rholang code you type, but first, let’s take a quick look under the hood.

Enter “0” (which means “do nothing.”)

rholang $ 0

You should see the contents of the tuple space (see below).



Hello World

Rholang is all about sending messages over channels, and that’s exactly what we’re going to see with the “Hello World” program.

At the repl prompt, enter:

rholang $ new stdout(`rho:io:stdout`) in { stdout!("Hello World") }

The message we sent was “Hello World”, and the channel we sent it on was stdout. The ! represents a send operation. So all together, the code means, send the message Hello World on the channel stdout.

So, if we sent a message, where the heck did it go? Well, it turns out that stdout is short for “standard output,” aka your computer screen. Flip back over to the first terminal that is still running your node and you’ll see the text.



Using Docker to set up and connect

To set up a standalone node, enter:

$ docker run -it --network rnode-net --name rnode0 rchain/rnode:latest run --standalone --no-upnp

Connect to the node by opening up a new tab in terminal and enter:

$ docker run -it --network rnode-net rchain/rnode:latest --grpc-host rnode0 repl

Now that the RNode repl is set up, we can now execute the Hello World program:

rholang $ new stdout(`rho:io:stdout`) in { stdout!("Hello World") }

New resources coming soon

RNode can do much more than run Rholang code, and you may consider diving deeper into running nodes for the RChain network.

If this post has left you confident about Rholang and ready to learn more, I have great news. We’ve spent the past few weeks working on a brand new tutorial for beginner and intermediate Rholang learners. Soon you’ll be able to experience Rholang design patterns in action, practice with plenty of exercises, and test your understanding as you go.

Need help?

Having trouble getting your code running? Join the co-op and attend “Colab” collaborative learning sessions Tuesdays at 1:00 PST to get help. In the meantime, you can try your rholang online at rchain.cloud.

