Coinmonks
Published in

Coinmonks

Hyperledger Besu — Getting Started: Part 2

This is Part 2 of the Hyperledger Besu implementation. In Part 1 we discussed the various features, consensus mechanism available.

Overview

In this tutorial, we will learn how to set up your Hyperledger Besu network and deploy your smart contract on the besu network. This article is intended for the developers who are invested deeply in the blockchain and want to get started with Hyperledger Besu.

Checkout my course on Hyperledger Besu

Hyperledger Besu is an Ethereum client designed to be enterprise-friendly for both public and private permissioned network use cases. It can also be run on test networks such as Rinkeby, Ropsten, and Görli. Hyperledger Besu includes several consensus algorithms including PoW, and PoA (IBFT, IBFT 2.0, Etherhash, and Clique). Its comprehensive permissioning schemes are designed specifically for use in a consortium environment.

Any enterprise-grade framework requires expertise to work. If you are a novice, you will find yourself struggling a lot to fix small things. That’s why it is important to start early and practice in your own way.

We will be setting up the following component

  1. 3 Besu Nodes
  2. 3 Orion Nodes (used for private transactions)
  3. 4 Validator Nodes
  4. File Beat + ELK(Elastic, Logstash, and Kibana)
  5. EthSigner (Transaction Signer)
  6. Grafana and Prometheus
  7. Block explorer

Approach

Besu implements the following consensus protocols:

We are going to use the IBFT 2.0 for this demonstration. The config property in the genesis file specifies the consensus protocol for a chain. You can find the genesis file in theconfig/besu directory of the repository. As of now, besu has good support for Clique and IBFT 2.0, and feel free to choose the consensus mechanism based on your requirements. To change the consensus just update it in the .env file.

Prerequisites

  1. docker
  2. docker-compose
  3. Metamask (chrome-extension)

Implementation

we are going to implement besu network that consists of three nodes and will be deploying the smart contract written in solidity. We will make transactions and query the smart-contract. Along with this, we will have Block explorer, Grafana dashboard to see the network metrics. We will deploy a smart-contact and will access it on the browser.

  1. Clone the repository
git clone https://github.com/adityajoshi12/hyperledger-besu.git

2. To start the network all you have to do is run the single script file.

./run.sh

once the process is completed, you will see something similar to this.

3. To deploy the smart-contract and run the dapp

cd dapps/pet-shop
./run_dapp.sh

this script will clone the pet-shop example repository and install the truffle and then it will deploy the contact on our besu network, if everything goes well, you will get output like this

4. After deploying the smart contract we can access the application athttp://localhost:3001/ . And it will ask you to connect metamask with the application. Please import the private key 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3 in the metamask to access the application.

when you connect metamask with besu network, use http://localhost:8545 as RPC endpoint and 2018 as the chainId.

on when you click on the adopt button it will make a transaction and your metamask will popup to confirm the transaction.

You can access the grafana dashboard at http://localhost:3000 to see the metrics of the network. And the block explorer is at http://localhost:25000

That’s all for this article. You can find the link to the repository here. In the next Part 3, we will deploy, transact, and query the contract using the NodeJs SDK. And also we will be implementing the privacy feature of Hyperledger Besu. We will be exploring the GraphQL support for besu in coming articles.

If you find this article helpful do hit the clap button and follow me for more such informative articles.

You can find me on Linkedin or stalk me on GitHub? If that’s too social for you, just drop a mail to adityaprakashjoshi1@gmail.com if you wish to talk tech with me.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditya Joshi

I am a Software Engineer @Walmart and instructor @Udemy, working on Blockchain, and Kubernetes. I have completed CHFA, CKA, CKAD