Maybe you’re working on your first Enterprise Ethereum blockchain project to require private transactions, or maybe you’re an expert in Quorum trying out Hyperledger Besu for the first time.
Either way we’ve done the work in Kaleido to understand the differences and tooling options out there, and simplify things wherever possible.
If you use our REST API Gateway, you’ll find today we’ve abstracted the differences between the technologies wherever possible into the gateway itself. By default we use one-time keys for submitting the ordering transactions for Hyperledger Besu + Orion, allow you to specify the signing key for the private transactions, and automatically manage a single privacy group for each list of privateFor addresses.
We’ve also done the work in our kaleido-js sample based on web3js to give you Javascript sample code to submit private transactions directly to a node over JSON/RPC.
We can use the kaleido-js package to deploy a private contract and submit private transactions in besu. This package comes handy when you want to deploy contract, send transactions, perform queries and also submit externally signed transaction. Go to github.com/kaleido-io/kaleido-js and clone or download the package to your local machine.
Once downloaded cd to the kaleido-js folder.
cd ~/kaleido-js/deploy-transact/
Install the required node packages
npm i
The first step is to deploy a private contract. The kaleido-js already has a Simple storage contract which we will use for this example. To deploy your own contract add your contract to the contracts folder. To deploy a private contract you will need:
Follow the below steps to get the connection URL and the orion address of the node:
Navigate to the environment containing the nodes.
Click on the node to navigate to the Node information page. The value displayed in PRIVATE TX PARTICIPANT is the Orion address of the node.
Click Connect Node button on the top right portion of the screen. In the Kaleido Connect page, click VIEW DETAILS under Native JSON/RPC
You will be taken to the app creds page. Create new app creds or use your existing app creds. Here we will create New app creds.
In the Kaleido Connect page, copy the value CONNECTION URL
Now, use the below command to deploy the contract. Here we deploy the private contract between nodes 1, 2 ad 3. The – -url is the connection url of node 1. The –privateFrom is the orion address of node 1 and –privateFor is the orion address of node 2 and node 3 separated by commas.
You should see the response similar to as follows:
Note down the contract address. This will be used in all further transactions.
Now let us invoke the set operation in simple storage. For this submit the transaction as follows:
DONE!
We can query the contract to check the value. We will submit query through node 2, so now the privateFrom field contains the orion address of node 2 and the privateFor field contains the orion address of node1 and 3 seperated by commas.
DONE!
Since this contract is only deployed in the privacy group formed by nodes 1, 2 and 3, the value we set is completely shielded from node 4.
If you aren’t already aware of this, please refer to Kaleido Smart Contract Management to learn more about this great feature. Let’s see how we can use the smart contract management feature to deploy a private contract and send private transactions in Besu. Follow steps
Your guide to everything from asset tokenization to zero knowledge proofs
Download NowLearn how Swift, the world’s leading provider of secure financial messaging services, utilizes Kaleido in its CBDC Sandbox project.
Download Now