Following this page provides guidance on setting up a local network using Docker, comprising a 4-node chain. This configuration serves as a valuable tool for developers seeking to test their applications and protocol functionalities within a multi-node environment.
Build & Start
To build start a 4 node testnet using docker, run:
make localnet-start
This command creates a 4-node network using the cvmdnode Docker image. The ports for each node are found in this table:
To update the binary, just rebuild it and restart the nodes
make localnet-start
The command above command will run containers in the background using Docker compose. You will see the network being created:
The make localnet-start creates files for a 4-node testnet in ./build by calling the cvmd mainnet command. This outputs a handful of files in the ./build directory:
Whereas the logs for the REST & RPC server would look like:
I[2020-07-30|09:39:17.488] Starting application REST service (chain-id: "7305661614933169792")... module=rest-server
I[2020-07-30|09:39:17.488] Starting RPC HTTP server on 127.0.0.1:8545 module=rest-server
...
Follow Logs
You can also watch logs as they are produced via Docker with the --follow (-f) flag, for example:
docker logs -f cvmdnode0
Interact with the Localnet
Ethereum JSON-RPC & Websocket Ports
To interact with the testnet via WebSockets or RPC/API, you will send your request to the corresponding ports:
You can send a curl command such as:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" 192.162.10.1:8545
Additional instructions on how to interact with the WebSocket can be found on the events documentation.
Keys & Accounts
To interact with cvmd and start querying state or creating txs, you use the cvmd directory of any given node as your home, for example:
cvmd keys list --home ./build/node0/cvmd
Now that accounts exists, you may create new accounts and send those accounts funds!
Special Binaries
If you have multiple binaries with different names, you can specify which one to run with the BINARY environment variable. The path of the binary is relative to the attached volume. For example:
# Run with custom binary
BINARY=cvm make localnet-start