10
Min Read

Submit Your First Private Transaction on Hyperledger Besu using Orion

Submit Your First Private Transaction on Hyperledger Besu using Orion
Update
Since this post was written, Hyperledger FireFly has reached 1.0. Learn more here!
Getting started with Besu+Orion private transactions on Kaleido

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.

Submitting transactions using the kaleido-js package

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:

  • The connection url of the node through which you want to deploy the contract
  • The orion address of the nodes, for which your need the contract to be deployed

Follow the below steps to get the connection URL and the orion address of the node:

Navigate to the environment containing the nodes.

Besu+Orion private transactions-1

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.

Besu+Orion private transactions-2

Click Connect Node button on the top right portion of the screen. In the Kaleido Connect page, click VIEW DETAILS under Native JSON/RPC

Besu+Orion private transactions-3

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.

Besu+Orion private transactions-4

In the Kaleido Connect page, copy the value CONNECTION URL

Besu+Orion private transactions-5

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.

node test.js –url=https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzvqa2weug-rpc.dev2.photic.io –deploy –besu_private –privateFrom=RReps2SdrlDI5v5cYRtziItNHZlw7lFjtNhs8amKwWc= –privateFor=WEb6fchCeCb/18YygqLjsmCBUB0qqxALhCsu7nfDExI=,ZWd0QyywLTNVusqi//JcUQYazt3dJJvxB3i1ldcKCm0=

You should see the response similar to as follows:

=> Connecting to target node: https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzvqa2weug-rpc.dev2.photic.ioFound account in the target node: 0x158CC890d0E0b73Aba1238a3400029e5846DF81A=> Deploying smart contractWaiting for transaction to be mined …Smart contract deployed, ready to take calls at “0xaea6b92b6dc737376a88d7738a0423f72f29aa7e”
Besu+Orion private transactions-6

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:

node test.js –url=https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzvqa2weug-rpc.dev2.photic.io –contract=0xaea6b92b6dc737376a88d7738a0423f72f29aa7e –set=7 –besu_private –privateFrom=RReps2SdrlDI5v5cYRtziItNHZlw7lFjtNhs8amKwWc= –privateFor=’WEb6fchCeCb/18YygqLjsmCBUB0qqxALhCsu7nfDExI=’,’ZWd0QyywLTNVusqi//JcUQYazt3dJJvxB3i1ldcKCm0=’=> Connecting to target node: https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzvqa2weug-rpc.dev2.photic.ioFound account in the target node: 0x158CC890d0E0b73Aba1238a3400029e5846DF81A=> Setting state to new valueWaiting for transaction to be mined …New value set to: 7

DONE!

Besu+Orion private transactions-7

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.

node test.js –url=https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzq5hjn2gb-rpc.dev2.photic.io –contract=0xaea6b92b6dc737376a88d7738a0423f72f29aa7e –query –besu_private –privateFrom=WEb6fchCeCb/18YygqLjsmCBUB0qqxALhCsu7nfDExI= –privateFor=RReps2SdrlDI5v5cYRtziItNHZlw7lFjtNhs8amKwWc=,ZWd0QyywLTNVusqi//JcUQYazt3dJJvxB3i1ldcKCm0==> Connecting to target node: https://zzop6ymmpf:B2QslYYRwzCNT48GMc5T-A4dIwu6ywmLhbTKijCTLwA@zzalhiud2y-zzq5hjn2gb-rpc.dev2.photic.ioFound account in the target node: 0x1025d27317086972cF76369976e09C059541c138=> Calling smart contract at “0xaea6b92b6dc737376a88d7738a0423f72f29aa7e” for current state valueWaiting for transaction to be mined …Smart contract current state: “0x0000000000000000000000000000000000000000000000000000000000000007”

DONE!

Besu+Orion private transactions-8

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.

Using Kaleido Smart Contract Management

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

Interested in Blockchain?

Start learning blockchain and creating enterprise solutions today with a free Kaleido account!

Create Free Account
Don't forget to share this article!
Interested in Blockchain?

Start learning blockchain and creating enterprise solutions today with a free Kaleido account!

Create Free Account

The Ultimate Enterprise Blockchain Glossary

Your guide to everything from asset tokenization to zero knowledge proofs

Download Now

Swift Utilizes Kaleido in New CBDC Sandbox

Learn how Swift, the world’s leading provider of secure financial messaging services, utilizes Kaleido in its CBDC Sandbox project.

Download Now

Related Posts

Privacy, Security, Scalability: Comparing UTXO vs. Account Model

Privacy, Security, Scalability: Comparing UTXO vs. Account Model

Marc Lewis
Managing Editor
Confidential UTXO Model: Enhancing Blockchain Privacy for Tokenization

Confidential UTXO: Preserving Privacy in Blockchain-Based Systems

Marc Lewis
Managing Editor
Blockchain Privacy for EVM: An Overview of the Evolving Landscape

Decoding Blockchain Privacy for EVM: An Overview of the Evolving Landscape

Ray Chen
Product Manager

Blockchain made radically simple for the enterprise

No Credit Card Required
ISO27K & SOC2 Type 2 Compliant
Free Training & Support