Hyperledger Besu is an enterprise-grade Ethereum client within the Hyperledger ecosystem, offering full compatibility with the Ethereum Mainnet. This tutorial demonstrates how to:
- Rapidly deploy an enterprise Ethereum network using Hyperledger Besu
- Query data and submit transactions using JSON-RPC
- Develop DApps with Truffle framework
- Utilize built-in tools for debugging and monitoring
1. Launching the Enterprise Ethereum Network
Begin by cloning the Besu quickstart repository:
git clone https://github.com/PegaSysEng/besu-quickstart.gitNavigate to the besu-quickstart directory and execute:
./run.shThis command builds a Docker image and launches 4 containers simulating an enterprise Ethereum network with 6 Besu nodes. Upon completion, you'll see:
*************************************
Besu Quickstart
*************************************
List endpoints and services
----------------------------------
Name Command State Ports
---------------------------------------------------------------------------------------------------------
besu-quickstart_bootnode_1 /opt/besu/bootnode_sta ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_explorer_1 nginx -g daemon off; Up 0.0.0.0:32768->80/tcp
besu-quickstart_grafana_1 /run.sh Up 3000/tcp
besu-quickstart_minernode_1 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_node_1 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_node_2 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_node_3 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_node_4 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
besu-quickstart_prometheus_1 /bin/prometheus --config.f ... Up 9090/tcp
besu-quickstart_rpcnode_1 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcpAccess endpoints include:
****************************************************************
JSON-RPC HTTP service endpoint : http://localhost:32768/jsonrpc
JSON-RPC WebSocket service endpoint: ws://localhost:32768/jsonws
GraphQL HTTP service endpoint : http://localhost:32768/graphql
Web block explorer address : http://localhost:32768
Prometheus address : http://localhost:32768/prometheus/graph
Grafana address : http://localhost:32768/grafana-dashboard
****************************************************************Key services:
- JSON-RPC HTTP: For DApp/MetaMask integration
- WebSocket: For real-time DApp connections
- GraphQL: Alternative query interface
- Block Explorer: Visualize blockchain data
- Prometheus/Grafana: Network monitoring
To redisplay endpoints:
./list.sh2. Using the Enterprise Ethereum Block Explorer
We recommend the Alethio lightweight explorer. Open the Web Block Explorer endpoint in your browser to inspect:
- All 6 Besu nodes (4 regular, 1 miner, 1 bootnode)
- Detailed block information via Best Block number
- Transaction/address searches using the search icon
๐ Explore enterprise blockchain solutions for advanced use cases.
3. Monitoring Node Health
Visualize network metrics using:
- Prometheus: Collects node performance data
- Grafana: Creates dashboards from Prometheus metrics
Access both tools via their respective endpoints.
4. JSON-RPC API Integration
Besu supports standard Ethereum JSON-RPC methods. Examples:
Check client version:
curl -X POST --data '{
"jsonrpc":"2.0",
"method":"web3_clientVersion",
"params":[],
"id":1
}' http://localhost:32768/jsonrpcGet peer count:
curl -X POST --data '{
"jsonrpc":"2.0",
"method":"net_peerCount",
"params":[],
"id":1
}' http://localhost:32768/jsonrpcQuery latest block:
curl -X POST --data '{
"jsonrpc":"2.0",
"method":"eth_blockNumber",
"params":[],
"id":1
}' http://localhost:32768/jsonrpc5. Account Management
Use these genesis accounts for testing:
Account 1 (Coinbase):
Address: 0xfe3b557e8fb62b89f4916b721be55ceb828dbd73
Private Key: 0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63
Balance: 200000000000000000000 WEIAccount 2:
Address: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57
Private Key: 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3
Balance: 2785365088392105618523029504 WEIConnect MetaMask to your Besu node to begin transactions.
6. Truffle Pet Shop Demo on Besu
Setup:
Install Truffle:
npm install -g truffleCreate project:
mkdir pet-shop-tutorial cd pet-shop-tutorial truffle unbox pet-shopInstall HD Wallet Provider:
npm install --save @truffle/hdwallet-provider
Configuration:
Update truffle-config.js:
const PrivateKeyProvider = require("@truffle/hdwallet-provider");
const privateKey = "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63";
module.exports = {
networks: {
quickstartWallet: {
provider: () => new PrivateKeyProvider(privateKey, "http://localhost:32768/jsonrpc"),
network_id: "*"
}
}
};Deployment:
truffle migrate --network quickstartWalletTesting:
truffle test --network quickstartWallet๐ Learn more about blockchain development with comprehensive guides.
7. Network Management
Temporary stop:
./stop.shRestart:
./resume.shComplete removal:
./remove.shFAQ
What makes Hyperledger Besu different from other Ethereum clients?
Besu offers enterprise features like permissioning, while maintaining full Ethereum Mainnet compatibility.
Can I use MetaMask with Besu?
Yes! Simply connect MetaMask to your Besu node's RPC endpoint.
How do I monitor transaction performance?
Use Grafana dashboards connected to Prometheus metrics for real-time monitoring.
What consensus mechanisms does Besu support?
Besu supports both Proof of Work (Ethash) and Proof of Authority (IBFT, QBFT, Clique).
How do I customize the genesis block?
Modify the config/besu/genesis.json file before initializing the network.
Can I deploy ERC-20 tokens on Besu?
Absolutely. Besu fully supports all standard Ethereum smart contracts.