How about some hands-on experience with blockchain? There are very few professionals with hands-on blockchain experience right now, meaning any amount of hands-on experience is a mighty fine feather to have in your cap. Furthermore, the brilliant thing about blockchain is how simple the technology behind the scenes can be.
Getting your hands dirty
The idea behind blockchain is what scientists call a paradigm shift. After conception it appears remarkably simple and obvious, yet it is radically different to anything that came before it. So, take advantage of this shift, learn how to create a blockchain system before anyone else realises how easy it is, and reap the rewards.
This blog is going to guide you in to making a “bank” backed by blockchain, without any prior development knowledge. Our bank is going to have limited functionality, and we are simply going to add the ability to transfer money between accounts. This isn’t anything flashy but the idea is to show you how the principles of blockchain function in reality.
We are going to be using Hyperledger Composer Playground, which is a great place to get started as you don’t need to worry about managing any underlying infrastructure, and it uses an industry leading open source framework. So, click on the link and let’s get started!
Step 1: Create a new network
Once you open Composer Playground, choose “Deploy a new business network”, as starting from scratch is the best way to build understanding.
The form that follows has little impact on your blockchain, enter information that matches your use case and choose “empty-business-network”.
Step 2: Defining your blockchain
Once you have created and named your business network you will be faced with today’s most daunting task. Defining how your blockchain functions – this is done using a .cto file which is Hyperledger’s own modelling language.
2.1 Creating your model.cto file
There are three artefacts you need to define when creating a blockchain: Assets, Participants, and Transactions. These are all defined in the model.cto file, so navigate there, delete the existing code and replace it with the following code:
Optional: If you would like to understand how this code works, this page provides a good overview explaining the details of the .cto file.
2.2 Adding a script file
2.3 Defining who can access your blockchain
The third and final thing you may want to add if you were doing this for a genuine system, would be an access control list (ACL). This is a file that defines who can do what on the blockchain. However, we aren’t going to be using it today
Step 3: Testing your blockchain
That’s it! Congratulations, you have now created your first blockchain network. Now your network has been created you can test a transaction and see how it hangs together.
Click the “Test tab” at the top of Hyperledger composer to can define customers, accounts and transactions by providing values for the attributes you specified in your model.cto file.
Now you have created the necessary artefacts for a transaction you can try to send money from one account to another. In the example to the right, I have sent £25.00 to Jimmy, identified by our account numbers. If you do the same, and you haven’t run in to any errors, the balance of your two accounts should have been updated too.
Congratulations, you’ve built your first blockchain application
Now that we have reached the end of the demo, you should have successfully created your first blockchain. Hopefully you agree that this wasn’t as intimidating as it sounds! Even though blockchain is cutting edge technology, it is built using simple principles, and thanks to organisations such as Hyperledger it is readily accessible and easy to use.
If you enjoyed this demo or are interested in the commercial applications of blockchain, or anything else about blockchain, get in contact with Capgemini Invent’s Blockchain Centre of Excellence, we are always happy to help.
Ryan is a consultant in Capgemini Invent’s New Digital Services and Platforms team. Ryan joined Capgemini Invent in early 2017 and his primary focus is digital banking. He is currently delivering a Microsoft Azure transformation project for one the largest banks in the UK.