We recently made available our first blockchain solution on the Azure Marketplace.
This sample environment provides RESTful services for creating and managing ERC-20 tokens on top of Quorum.
It provides a 3-node Quorum environment and RESTful service endpoints for interacting with each of those nodes over HTTP. These services are provided via the erc20-rest-service which uses web3j and Spring Boot.
Full transaction privacy is supported thanks to Quorum.
Getting started
Create the machine image as per a usual Azure VM image, We recommend you use a DS1 v2 or better host, due to the memory requirements of running a Quorum cluster on a single VM.
You should use ubuntu as username, then deploy the host as per a normal Azure VM.
Once available on Azure, logon to the host, and start the application with the following commands:
cd erc20-quorum-vm-example
./init.sh
This will start a 3-node Quorum cluster using RAFT consensus, and 3 instances of our ERC-20 RESTful service.
Deploying our ERC-20 contract
The
ERC-20 token standard is an Ethereum standard for implementing smart contracts that provide tokens on the Ethereum network. It provides a common set of methods that these contracts should implement.
Each of these services are available at the following URLs:
At each URL there should be a Swagger UI that looks like the below.
You’re now ready to experiment with the service itself.
Provide the following parameter values
contractSpecification:
{
"initialAmount": 1000000,
"tokenName": "QToken",
"decimalUnits": 0,
"tokenSymbol": "Q$"
}
privateFor:
1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=
Then click the Try it out! button.
You should see a response like the below:
Congratulations you’ve just deployed a smart contract to a Quorum network! It uses Quorum’s transaction privacy to ensure that the transaction is only visible between two parties on the three party network.
The address of the smart contract on the network is the response body:
In this case its:
0x938781b9796aea6376e40ca158f67fa89d5d8a18
Demonstrating Quorum’s transaction privacy
Let’s now prove that the contract is only available to a subset of parties on the network.We can do this by calling any method on the smart contract. If we’re allowed to view the smart contract we’ll get a result back, otherwise we won’t.
We’re going to call the symbol method on the contract from each of our nodes.
We start with our first node:
Enter the contract address we have been provided with (0x938781b9796aea6376e40ca158f67fa89d5d8a18)
Click Try it out!
You should see the symbol name Q$ in the response body showing that our first node can access the contract.
Now try doing the same on our second node:
This time around you’ll get a different response, as the second node was not privy to the transaction.
Hence the request fails returning a HTTP 500 response:
{
"timestamp": 1505302053178,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.RuntimeException",
"message": "Empty value returned by call",
"path""/0x938781b9796aea6376e40ca158f67fa89d5d8a18/symbol"
}
Finally we try with the third node which is successful, as this node was privy to the transaction.
Closing remarks
This demonstrates the transaction privacy of Quorum.
Alternatively you can perform these actions without taking advantage of the transaction privacy of Quorum, leaving the privateFor field blank. Then the demo runs much like it would on a normal Ethereum network, but with Quorum’s fast RAFT consensus mechanism.
There are a number of other methods you can call as per the ERC20 token standard. We encourage you to have a play.
Please feel free to
contact us if you have any questions or want to chat.