Hyperledger Burrow Overview
Hyperledger Burrow is an enterprise blockchain network that provides a permissioned smart contract interpreter to execute business logic following the Ethereum Virtual Machine (EVM) specifications.
Hyperledger Seth is the Sawtooth-Ethereum integration project. It integrates the Hyperledger Burrow implementation of the EVM with Hyperledger Sawtooth to provide support for running Ethereum smart contracts on the Hyperledger Sawtooth platform.
For those who are not familiar with Hyperledger project Intro to Hyperledger Family and Hyperledger Blockchain Ecosystem and Hyperledger Design Philosophy and Framework Architecture articles are strongly recommended.
To better follow and understand this recipe, it is advisable to read Essential Hyperledger Sawtooth Features for Enterprise Blockchain Developers, Blockchain Developer Guide- How to Install and work with Hyperledger Sawtooth , Configuring Hyperledger Sawtooth Validator and REST API and Blockchain Developer Guide- How to Install Hyperledger Seth and Docker on AWS articles in advance.
In our previous recipes, we reviewed i- Ethereum, Solidity and how to use Hyperledger Seth to build blockchain application with Ethereum and ii-How to install Hyperledger Burrow on AWS, and iii- How to write smart contracts with Solidity. We will deploy and run the sample contract on Burrow in this recipe.
Build Solidity Compiler
In order to deploy the sample contract written (in our previous recipe) with Solidity onto Burrow, the Solidity compiler needs to be installed on Linux:
1. Install the Solidity compiler:
sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update
sudo apt-get install solc
2. Verify that the Solidity compiler, solc, is installed with the following command:
ubuntu@ip-172-31-90-67:~/go/src/hello$ solc –version solc, the solidity compiler commandline interface Version: 0.4.25+commit.59dbf8f1.Linux.g++
Deploy Smart Contracts on Hyperledger Burrow
Execute the following steps to deploy and run smart contract:
1. Define the Burrow deploy configuration file for the Solidity contract. The deploy file for the BasicContract.sol sample contract is the basiccontractdeploy.yaml file. It specifies the job as deploy and the Solidity contract file as follows:
name: BasicContract deploy:
2. Deploy the Solidity contract. After both the BasicContract.sol contract file and the basiccontractdeploy.yaml deploy file are written, the contract can be deployed to the Burrow validator with the burrow deploy command:
burrow deploy –address=54EF1517D97E7A653D5FA5B05060A82A8856515D -f basiccontractdeploy.yaml
The output should be as follows:
ubuntu@ip-172-31-90-67:~/burrow/example/basic$ burrow deploy — address=54EF1517D97E7A653D5FA5B05060A82A8856515D -f basiccontractdeploy.yaml
Job Name => defaultAddr
Job Name => BasicContract
Deploying Contract name => BasicContract
addr => 5486CD7F1453396A1C9E4B24CC07AA507C4CD88A
Saving Binary =>
Writing [basiccontractdeploy.output.json] to current directory
The deployed contract address is in the preceding output. For our contract, it’s 5486CD7F1453396A1C9E4B24CC07AA507C4CD88A, which will be used when calling this contract.
3. Call the contract. To call the deposit function in the sample contract, specify the Burrow deploy configure file, basiccontractdeposit.yaml, as follows:
name: deposit call:
function: deposit data:
4. Run the Burrow CLI command:
burrow deploy –address=54EF1517D97E7A653D5FA5B05060A82A8856515D -f basiccontractdeposit.yaml
5. To call the withdraw function in the sample contract, specify the Burrow deploy configure file, basiccontractwithdraw.yaml, as follows:
name: withdraw call:
function: withdraw data:
6. Run the Burrow CLI command:
burrow deploy –address=54EF1517D97E7A653D5FA5B05060A82A8856515D -f basiccontractwithdraw.yaml
7. To call the getBalance function in the sample contract, specify the Burrow deploy configure file, as follows:
name: getBalance query-contract:
name: getAddress query-contract:
8. Run the Burrow CLI command:
burrow deploy –address=54EF1517D97E7A653D5FA5B05060A82A8856515D -f basiccontractquery.yaml
The output for the query should look as follows:
ubuntu@ip-172-31-90-67:~/burrow/example/basic$ burrow deploy
Job Name => defaultAddr
Job Name => getBalance
Return Value => 800
Job Name => getAddress
Return Value => 54EF1517D97E7A653D5FA5B05060A82A8856515D Writing [basiccontractquery.output.json] to current directory
Put Things Together
The Burrow blockchain is composed of validator peer nodes. Burrow provides CLI commands to interact with the network. The burrow deploy CLI command is used to deploy the smart contract and trigger transactions on the deployed contract account. Its main options are as follows:
ubuntu@ip-172-31-90-67:~/burrow/example/basic$ burrow deploy –help Usage: burrow deploy [OPTIONS]
Deploy and test contracts
-u, –chain-url chain-url to be used in IP:PORT format (default “127.0.0.1:10997”)
-s, –keys IP:PORT of Burrow GRPC service which jobs should or otherwise transaction
submitted unsigned for mempool signing in Burrow
-f, –file path to package file which jobs should use. if also using the –dir flag, give the relative path to jobs file, which should be in the same directory (default “deploy.yaml”)
-a, –address default address to use; operates the same way as the [account] job, only before the deploy file is ran
To deploy and trigger transactions with the burrow deploy command, the validator address and the RPC URL (the default is 127.0.0.1:10997) will be used. These are defined in the generated Burrow validator configuration file, burrow.toml, as follows:
Address = “54EF1517D97E7A653D5FA5B05060A82A8856515D”
Amount = 9999999999
Name = “Full_0”
Enabled = true
ListenAddress = “tcp://127.0.0.1:26658”
Enabled = false
ListenAddress = “tcp://127.0.0.1:6060”
Enabled = true
ListenAddress = “127.0.0.1:10997”
To deploy and test the contract, the deploy configure file should be provided as an option, indicated by -f. In the file, jobs are defined. To define a job, you need to provide the following:
- A name: A user-friendly job name.
- The job type: deploy, call, or query-contract. We used the three job types in this recipe to deploy contracts, call transactions to withdraw money, and query the balance of the account.
- The destination: The contract account address.
- The function: The name of the function in the Solidity contract.
- The data: The parameters to call the function.
This recipe is written in collaboration with Brian Wu who is a senior Hyperledger instructor at Coding Bootcamps school in Washington DC.