Plugin to enable the creation of a Hyperledger Besu blockchain using Fogbed.
This package allows the creation of a private blockchain using IBFT 2.0 or QBFT consensus protocols.
sudo pip install fogbed
fogbed install
sudo pip install -U git+https://github.com/larsid/fogbesu.git
Copy the Dockerfile in this repository to build a compatible Fogbed Docker image and build it with:
sudo docker build -t besu .
Save the example below to a file and run with fogbed run example.py.
from fogbed import FogbedExperiment
from fogbesu import BesuBlockchain
if(__name__=='__main__'):
exp = FogbedExperiment()
besu1 = exp.add_virtual_instance('besu1')
network = {
besu1: ['node1', 'node2', 'node3', 'node4', 'node5'],
}
blockchain = BesuBlockchain(
experiment=exp,
bootnode='node1',
config_file='configFile.json',
network=network
)
blockchain.run()Important
Copy the configFile.json to the same directory as the experiment. This is the genesis file that defines the blockchain configuration.
from fogbed import FogbedDistributedExperiment
from fogbesu import BesuBlockchain
if(__name__=='__main__'):
exp = FogbedDistributedExperiment()
besu1 = exp.add_virtual_instance('besu1')
besu2 = exp.add_virtual_instance('besu2')
worker1 = exp.add_worker(ip='192.168.0.150', port=5000)
worker2 = exp.add_worker(ip='192.168.0.151', port=5000)
worker1.add(besu1, reachable=True)
worker2.add(besu2, reachable=True)
exp.add_tunnel(worker1, worker2)
network = {
besu1: ['node1', 'node2'],
besu2: ['node3', 'node4']
}
blockchain = BesuBlockchain(
experiment=exp,
bootnode='node1',
config_file='configFile.json',
network=network
)
blockchain.run()Run a worker in each machine with fogbed worker -p=5000 and execute the script.
To learn more about deploying contracts, integrating the frontend, and performing transactions using MetaMask, refer to Hyperledger Besu detailed documentation: