A quick tutorial with code examples
Hey there, if you’re reading this you’re probably looking to get Corda set up in a cloud provider. This is a short and sweet guide to help you do that without too much pain.
Step 1: Set up your network
In our setup, we have a simple network with four nodes running on two virtual machines. The main requirement, of course, is that the nodes must be able to reach each other.
Start by opening the google cloud console and provisioning two nodes on your favourite Linux distribution. (In my case, I’ll pick the latest version of ubuntu). My recommendation for a Corda node is at least an e2-standard-2.
If you’re looking to get a demo working, I’d recommend a simple set of firewall rules that allow all traffic. Once you’ve done that you can ensure the nodes can communicate with a simple
Once you have tested the connection and you believe the nodes can communicate, you should be aware of the danger of allowing all traffic to the group. It is not safe to allow all inbound traffic on a production instance of pretty much anything.
One last thing to do before you go on to access the nodes is to modify your codebase.
I’ve set up a repository for this tutorial on GitHub. Download this repository and you’ll notice a
VM1 folder and a
VM2 folder. You’ll also see a
commands.sh that contains code you can use when provisioning the actual machine. So two of our Corda nodes, the Notary and “Party A” will run on
VM1. The other two of our Corda nodes, the “Party B” and “Party C” will run on
Both of those folders have similar contents, and you need to make sure that you add the public IP addresses of the Corda nodes to align with the VMs that they’re going to run on.
Take the IP address of the ec2 instance that will run VM1’s nodes, and then add its IP address to the
For example, if the node’s IP address was
126.96.36.199 Then the resulting file would look like this:
Now add that same IP for the
p2pAddress of the
VM2 nodes. (Party B and Party C).
Once that bit of housekeeping is done, you’re ready to copy these folders onto the virtual machines.
Step 2: Run Corda
Once you’ve got ssh access, copy your folders onto the virtual machines. After a quick
rsync you should be all set. After copying over the folder, just run the
commands.sh file I provided in the root of the repository. If all goes well, the virtual machines will be able to run docker without any issues.
Once you’re in,
cd into the folders for each VM and run the following docker command with the right file:
Note: Docker may show an error about not having permissions to write to a database file, if you see that just make sure to change the permissions of the VM directory to make sure that both your user and the ‘docker’ user can write to them.
Step 3: Test your network
You can log into the node explorer using a specific virtual machine’s IP address and the node port specified in the
rpcSettings address of the node conf. (In this case, it’s 10006 for Party A).
The username and password are also specified in the node.conf, so we’ll use them here.
If all goes well and the nodes can communicate with each other, you’ll be able to see nodes from VM1 and VM2! Not bad!
That about covers it! Once you’re in the node explorer, you’re able to interact with your network, create transactions, run vault queries, and more!
And just for convenience, the link to that github repo is here.
You can also find a video version of this tutorial on youtube here.
Happy Coding ~
Want to learn more about building awesome blockchain applications on Corda? Be sure to visit https://corda.net, check out our community page to learn how to connect with other Corda developers, and sign up for one of our newsletters for the latest updates.
— David Awad is a Developer Evangelist at R3, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.
Follow David on Twitter here.