# Deploy IBFT2 using the configuration file
## Prerequisite
- Clone repo https://gitlab.com/Fagr/bc-hyperledger-besu.git
- Install Besu Command line from documentation https://besu.hyperledger.org/en/latest/HowTo/Get-Started/Install-Binaries/
- Install docker and docker-compose to run Grafana, Prometheus and Blockchain explorer
## Run
To two bootnodes and six validators
```javascript
./run.sh
```
To one bootnodes and three validators
```javascript
./run-four.sh
```
## Test
To test Blockchain make a curl request
```javascript
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' loclahost:8545
```
To run Grafana, Prometheus and Blockchain explorer
```javascript
./graph.sh
```
Grafana: port 3000
Prometheus: port 9090
Blockchain-explorer: port 8080
NB: We can make run all nodes and graphs at the same time. But we separate scripts to reduce memory usage.
## Stop/Pause Blockchain
```javascript
./stop.sh
```
## Delete Blockcian
```javascript
./down.sh
```
# Deploy IBFT2 using the quickstart
## Prerequisite
- Clone repo git clone https://gitlab.com/Fagr/beso-ethereum-reloader.git
- Install docker and docker-compose.
## Run
To one bootnodes and three validators
```javascript
./run.sh -c ibft2
```
## Test
To test Blockchain make a curl request
```javascript
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' localhost:8545
```
## Stop/Pause Blockchain
```javascript
./stop.sh
```
## Stop/Pause Blockchain
```javascript
./resume.sh
```
## Delete Blockchain
```javascript
./remove.sh
```
# Migration: Deploy smart contract on blockchain
## Prerequisite
- Intsall truffle
```javascript
npm install -g truffle
```
## Compile
```javascript
truffle compile
```
The compile command creates a `build/` directory, This directory transfer all our solidity code to build files.
## Migration
The migration process is to deploy the `build/` to our blockchain
```javascript
truffle migrate --network besu
```
## Usage
To use the migrated contracts you need to copy `build/` to your project root directory
## Common Errors
1- Each time you delete the blockchain or switch between docker or configuration file you need to `migrate` and change `build/`
2- When you try to migrate it keeps give you `everything is up to date` then try `truffle migrate --network besu --reset`
3- After migration, if you got error `network doesn't exist` or the Total cost wasn't 0 ETH.
open `truffle-config.js`
a) Check these global variables
const PrivateKeyProvider = require("@truffle/hdwallet-provider");
const privateKey = "684394f8d5cbfd47e4c86246525801dbd3bbde68ddcf894d2291dedfbd43e604";
/** Besu initialization */
const privateKeyProvider = new PrivateKeyProvider('0x'+privateKey, "http://localhost:8545");
b) Inside `networks` object make sure the besu is intialized
quickstartWallet: {
provider: privateKeyProvider,
gas: "0x1ffffffffffffe",
gasPrice: 0,
network_id: "*"
},
c) Some processes may fail after long time of deployement so we use reloader to refresh blockchain after a long time of deployment
https://gitlab.com/Fagr/beso-ethereum-reloader
# MicroService variables
adminPK=0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63
actually it is a secretkey