Setting Up a Local Multi-Validator Testnet
An end-to-end guide on creating a local Maroo testnet with multiple validators, starting the network, and interacting with it by checking balances and sending transactions.
What You Will Learn
- ✓How to generate a 4-node testnet configuration using `marood testnet`.
- ✓How to start all validator nodes simultaneously.
- ✓How to query the balance of a pre-funded validator account.
- ✓How to send tokens from one validator to another.
Prerequisites
- You have successfully compiled the `marood` binary from source.
Tools Needed
Go (1.21+)Maroo source code
In this tutorial, you will use the powerful
marood testnet command to spin up a complete, local Maroo blockchain. This is the fastest way to get a development environment running for testing smart contracts and applications. 1
1. Generate Testnet Files
First, we'll generate the configuration for a 4-validator network. This single command will create four node directories, each with its own keys and configuration, plus a shared genesis file that funds each validator and registers them in the network from block 1.
terminal bash
marood testnet -v 4 -o ./my-local-testnet --starting-ip-address 127.0.0.1 Note: This command will print the addresses and mnemonics for the 4 validator accounts. Save these, as you'll need them later. The output files will be in the `./my-local-testnet` directory.
2
2. Start the Network
Now that the configurations are generated, you need to start each of the four nodes. Open four separate terminal windows. In each terminal, run the
start command, pointing to the correct node directory. terminal bash
marood start --home ./my-local-testnet/node0 terminal bash
marood start --home ./my-local-testnet/node1 terminal bash
marood start --home ./my-local-testnet/node2 terminal bash
marood start --home ./my-local-testnet/node3 Tip: You should see logs in each terminal indicating that blocks are being produced. This confirms your local network is running!
3
3. Query an Account Balance
Let's verify that the validator accounts were funded correctly. Pick one of the validator addresses that was printed in Step 1 (it should start with
maroo1...). Use this address with the query bank balances command. You'll need to specify the RPC endpoint of one of your running nodes. terminal bash
# Replace maroo1... with the actual address of node0
marood query bank balances maroo1... --node tcp://127.0.0.1:26657 4
4. Send a Transaction
Finally, let's perform a state change by sending some
aokrw from validator 0 to validator 1. You will need the addresses for both. The testnet command also created local key names for each validator (validator0, validator1, etc.) which we can use as the sender. terminal bash
# Replace maroo1... with the actual address of node1
# The chain-id is 'test-chain-...' from the testnet output
marood tx bank send validator0 maroo1... 100aokrw \
--from validator0 \
--keyring-backend test \
--home ./my-local-testnet/node0 \
--chain-id <your-chain-id> \
--node tcp://127.0.0.1:26657 -y Warning: The `testnet` command uses the `test` keyring backend for simplicity. You must specify `--keyring-backend test` when sending transactions from these accounts.
Conclusion
Congratulations! You have successfully created, started, and interacted with a local multi-validator Maroo testnet. You now have a stable and realistic environment for developing and testing your decentralized applications on Maroo.