The output private keys will be used as input for the next step.
A validator needs two private keys: one ed25519 key for consensus engine (tendermint) and one secp256k1 key for operate it using smart contracts. Now we pick the secp256k1 key out from above generated keys. We just choose the first one and show its corresponding address:
After successfully executing the above commands, you can find the initialized data in the ~/.smartbchd directory. By using the --home option for ./smartbchd command, you can specify another directory. In the ~/.smartbchd directory, the genesis file specifies that all the EOAs corresponding to the above private keys will have a balance of 1000000000000000000000000000000.
Step 3: generate genesis validator consensus key info
Now we generate the ed25519 private key for consensus engine:
The output hex string is consensus pubkey which will be used in generate-genesis-validator command, and a file containing the consensus public and private key is generated under the current directory, named priv_validator_key.json.
Since now we are just running a single node for test, the key file is not so important. In production, a validator's operator must take good care of this key file priv_validator_key.json and back it up safely.
Step 4: generate genesis validator info using pubkey generated above
Using the hex string outputted at the last step as the argument, we call add-genesis-validator. It adds one validator's information into the genesis file. You can use this command repeatedly to add more validators. Since we only need one validator for single node test, here we just use this command once.
Step 6: copy priv_validator_key.json generated in Step 3
cp./priv_validator_key.json~/.smartbchd/config/
Thus, when this node starts up, it can use the private consensus key.
You can also ignore the unlock argument to unlock no accounts.
This command starts the node which provides JSON-RPC service at localhost:8584. You can use the --http.addr option to select another port other than localhost:8584. We unlocked accounts created at genesis, which can be shown using the following command:
You can also use --mainnet-url option to specify a bitcoincashnode's RPC endpoint, and use --home option to specifiy another data directory other than ~/.smartbchd .
# Run this command in another terminal:curl-XPOST--data'{"jsonrpc":"2.0", "method":"eth_accounts", "params":[],"id":1}' \-H"Content-Type: application/json"http://localhost:8545|jq