besu --version //check if Besu is installed
brew uninstall besu //uninstall Besu
brew install besu //install Besu (assuming you have already tapped it first with brew tap hyperledger/besu)
brew cask install adoptopenjdk
Starting Besu
To start Besu, just type
besu
This will start Besu pointing it to mainnet. This means that the blockchain will start to synchronise with the real Ethereum blockchain. A database folder (where the blockchain will be stored) will appear at usr/local/Cellar/besu/1.3.8/ which is where homebrew installed besu.
For testing purposes, start Besu with the network flag of dev
besu --network=dev
The other option is to use a config file and then specific the network, as well as other parameters there.
data-path="besudata"
network="dev"
miner-enabled=true
miner-coinbase="0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
rpc-http-cors-origins=["all"]
host-whitelist=["*"]
rpc-ws-enabled=true
rpc-http-enabled=true
Then reference the config file with:
besu --config-file="/User/sean/config.toml"
Note that flags in the command line override flags in the config file. For a complete list of other command line options, visit: http://besu.hyperledger.org/en/stable/Reference/CLI/CLI-Syntax/
Checking Besu network
To confirm the network you are connected to, you want to query the Besu API for the net_version.
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' localhost:8545
You can find out what net_version does along with all the other API options here.
However, in order for this to work, Besu must be started with the flag:
--rpc-http-enabled
Exercise
Enable rpc-http in a config file, but override it in the command line and prove that the override was successful
besu --config-file=/Users/sean/config.toml --rpc-http-enabled="false"
Running the following curl command should yield a “failed to connect error”.
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":45}' localhost:8545
curl: (7) Failed to connect to localhost port 8545: Connection refused
Changing the Besu network
So far we have specified the development network with the flag
--network=dev (or in the config file as network="dev")
or omitting the flag defaults to mainnet. However, there are 6 other networks that can be chosen. Ropsten, Rinkeby, Goerli, Classic, Mordor and Kotti. eg:
besu --network=ropsten
Fun fact: “Testnets are named after train stations as a convention, usually where the respective testnet maintainers are based from.”
- Morden: a subway station in London
- Ropsten: a metro station in Stockholm
- Rinkeby: a metro station in Stockholm
- Kovan: a subway station in Singapore
Changing the data dir
It is advisable to change the data directory to another location of your choice. This is because it can get quite large. Use the flag:
–data-path=<PATH>
For a complete list of Besu command line, visit http://besu.hyperledger.org/en/stable/Reference/CLI/CLI-Syntax/