Skip to content

web3labs/quorum-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quorum Token Java Sample

This project demonstrates the creation and management of a private token on a Quorum network.

Quorum privacy is used, only certain members of the network are privy to the token that has been created.

It is written in Java using web3j which is maintained by Web3 Labs.

Prerequisites

A Quorum network running with at least 3 transaction nodes. Check next section for an example of a ready to use network.

You will need the following details for each node:

  • Node URL, http://<node-url>:<node-port>
  • Transaction enclave address, <base64 encoded public key>

Quorum-dev-quickstart

As an example of a Quorum network that can be used with this sample project, we have the Quorum-dev-quickstart. This, will spin up a network of 3 members with their private transactions managers and will let you demo privacy groups and how they work.

Running the application

You will need to update the TokenApplication class with details of the URL for each of your transaction nodes and their associated public keys.

// FIXME: Add node URL and transaction node keys here
Node nodeA = createAndUnlockAccount("nodeA", "http://<node-url>", "<transaction node key>");
Node nodeB = createAndUnlockAccount("nodeB", "http://<node-url>", "<transaction node key>");
Node nodeZ = createAndUnlockAccount("nodeZ", "http://<node-url>", "<transaction node key>");

Where your node url would be similar to https://<app>.<yourdomain>.com:3200/{} and the nodekey would be a base64 encoded public key such as V4pb2lVRMwLZXGGmm/Ee3Y2U7BTlQ+BO8abrktMbSSQ=.

Then to run the application, simply type:

./gradlew run

The application logs the different activities it completes, which are as follows:

  1. Create an Ethereum account on nodes A, B and Z.
  2. Deploy a Quorum Token (symbol QT) contract that is visible only to nodes A, and B but not Z.
  3. Transfer QT to accounts associated with nodes A, B, Z.
  4. Display all account balances.
  5. Demonstrate that node Z cannot see the QT assigned to its account.
  6. Decrease the supply of QT.
  7. Display all account balances.

There are also a couple of integration tests you can use to test the application.

Viewing contracts and transactions

The Web3 Labs blockchain explorer provides an easy to use UI for browsing transaction and contract details.

git clone https://github.com/blk-io/epirus-free.git
cd epirus-free
NODE_ENDPOINT=http://<node-url> docker-compose up

You may access the blockchain explorer via http://localhost.

Latest blocks

You can then browse the smart contract that was created by obtaining the token contract address, which is logged as follows:

19:53:10.853 [main] INFO  c.w.quorum.token.TokenApplication - Quorum Token (QT) created at contract address 0x<contract-address>, by account 0x<creation-account>

You can view the contract itself via the url http://localhost:5000/contract/0x<contract-address>:

Contract

You can also view the private transactions:

Private transactions

And details of those transactions:

Transaction details

If you wish to learn more about our Epirus contract registry and blockchain explorer, including our production-ready SaaS offerings which include features such as authentication and BI integrations please contact us.