There are many Blockchain use-cases that calls for a private Blockchain network between a group of participants. One example is Project Ubin - a project initiated by the Monetary Authority of Singapore that tests the use of a private distributed ledger for clearing and settlement of payments and securities between banks. Another example is a private supply chain network where a group of suppliers, distributors and end users track goods as they move across the supply chain.
Kaleido is a solution that lets you create Ethereum and Quorum-based Blockchain networks quickly and hassle-free. This is a step-by-step about creating an Ethereum-based private Blockchain network in less than 10 minutes.
Setting up Kaleido
Begin by creating a new Kaleido account. And then sign in.
Then create a Consortium. Think of a Consortium as a collection of participants that is coming together for a common purpose, say, a group of suppliers and distributors for a private Blockchain-based supply chain network.
Then state the Consortium's mission and select the location that you wish the Blockchain network to be hosted.
Then add a new Environment. You can think of the Environment as the Blockchain network that the organizations will participate in.
Give the environment a name and decide if you want this to be an Ethereum Blockchain network, or a Quorum-based one. If you wish this to be Ethereum-based, choose Geth.
Press [Finish] to deploy this environment. The feature "RELAY SNAPSHOT OF BLOCK HASH TO MAINNET" is an ingenious method that the folks at Kaleido have created to write a snapshot of this private Blockchain at a specific time to the public Ethereum network.
Why is this useful? Bear in mind that this is a private blockchain network so it is theoretically possible for a group of rogue nodes to come together to collude and make unauthorized changes to past transactions on the Blockchain. To prevent this, a snapshot of this Blockchain can be saved on the public Ethereum network so that a block hash on the private network can be counter-checked against what's written to the public Blockchain. In this tutorial, we will leave this feature unchecked.
Then we add a node. The more nodes you have in a Blockchain environment, the more participants will be there to ensure that this Blockchain network stays alive, healthy and well validated. If you are building a private supply-chain network, you can think of every node as a participant.
State the node's owner and give the node a name.
Decide the resources you want your node to use.
That's it! You now have a running single-node Ethereum based private Blockchain!
Connecting to a Node
With a running node, new blocks start to get mined continuously. Currently, every block generated on your private Ethereum Blockchain contains no transaction. To execute transaction, we need to allow people to connect to the nodes. To do this, add a new App Credentials.
Give your application a name.
Make a copy of the username and password that will let you connect to your private Blockchain.
You will also need to know your node's address. To see it, click on the name of the node that you just created.
Copy the RPC endpoint address. You now have the username, password and the address to access this node.
From your Chrome Browser, login to MetaMask and select Private Network. If you have not installed your copy of MetaMask, get one here. MetaMask is an Ethereum wallet that lets you run transactions from your Chrome browser. Select "Custom RPC" because we are accessing a custom Ethereum network, and not one of the public ones.
At this stage, it will be important to have taken note the RPC endpoint address as well as the username and password to connect to this node. Assuming that your username is x and your password is y and the RPC endpoint address is https://myprivateethereum.com, enter the following in the "New Network" textfield:
https://x@y:myprivateethereum.com
Before your account in MetaMask can execute any transaction it needs Ethers. Unlike the public Ethereum Blockchain network, you don't need to exchange real cash for Ethers.
Copy the address.
Under the "Ether Pool" services, select "Fund Account".
Paste the account's address and enter 10 for amount. We are giving away 10 ETH to this account. If you were the owner of a private supply-chain network, you could probably probably "sell" these ETH as subscription for your service.
Hang on while this transaction gets written onto the ledger. When it's done, you will see new ETH appearing in your account.
Executing a Smart Contract
With available funds in your MetaMask wallet, we are now ready to deploy a Smart Contract on our private Ethereum Blockchain.
Visit Remix. Add a new smart contract "hello.sol". Copy and paste the mortal/greeter smart contract codes into Remix browser. Now compile it with the correct Solidity version stated in line 1.
Make sure that MetaMask is still turned on, the Environment says "Injected Web3" and the account that is going to be used to deploy this contract is the same one that you have given Ethers to.
Now enter a text, for example, "testing" into the _greeter setter and click [transact]
Your MetaMask wallet comes up to ask you to confirm the transaction. Note that all transaction entails some gas fee, in this case, 0.000278 ETH.
Wait for the contract to be deployed, the click [greet] to view the contents of the greet variable in the Smart Contract that you have just deployed to your private Ethereum Blockchain.
Exploring Blocks
Like how you could view transactions in each block with Etherscan, you can do the same with Kaleido. Under the "Block Explorer" services, click "Explore".
Notice that the most recent transaction is the creation of a new smart contract. Click to see it.
Click again to view its byte codes.
You can verify the source code for your mortal/greeter smart contract. Enter:
- Contract Name: greeter
- Compiler: <state the compiler version you used to compile this contract.
Click [Validate Code]. You source code can now be seen by anyone with access to your private Ethereum Network if he looks at this contract.
What's Next?
Kaleido has made is so easy for enterprises to deploy Ethereum based private Blockchain. Every once in a while, a killer app appears, turning an otherwise obscure technology into one that's widely adopted. Think VisiCalc on the micro computer, the iPhone for Smartphones and Super Mario for the Nintendo video game console.
In Ethereum, I believe 2 apps will make a difference in helping Ethereum-based Blockchains gain widespread adoption. The first is the MetaMask wallet and the second could perhaps be Kaleido. Deploying private Blockchain can't get any easier than this!
Photo by Paul Talbot on Unsplash