# Testnet
Learn how to deploy a local testnet or connect to an existing public one
# Pre-requisite Readings
# Single-node, Local, Manual Testnet
This guide helps you create a single validator node that runs a network locally for testing and other development related uses.
# Initialize node
Monikers can contain only ASCII characters. Using Unicode characters will render your node unreachable.
You can edit this moniker
later, in the $(HOME)/.ethermintd/config/config.toml
file:
You can edit the $HOME/.ethermintd/config/app.toml
file in order to enable the anti spam mechanism and reject incoming transactions with less than the minimum gas prices:
# Genesis Procedure
# Run Testnet
Now its safe to start the daemon:
You can then stop the node using Ctrl+C.
# Multi-node, Local, Automated Testnet
# Build Testnet & Start Testnet
To build start a 4 node testnet run:
This command creates a 4-node network using the ethermintdnode
Docker image.
The ports for each node are found in this table:
Node ID | P2P Port | Tendermint RPC Port | REST/ Ethereum JSON-RPC Port | WebSocket Port |
---|---|---|---|---|
ethermintnode0 | 26656 | 26657 | 8545 | 8546 |
ethermintnode1 | 26659 | 26660 | 8547 | 8548 |
ethermintnode2 | 26661 | 26662 | 8549 | 8550 |
ethermintnode3 | 26663 | 26664 | 8551 | 8552 |
To update the binary, just rebuild it and restart the nodes
The command above command will run containers in the background using Docker compose. You will see the network being created:
# Stop Testnet
Once you are done, execute:
# Configuration
The make localnet-start
creates files for a 4-node testnet in ./build
by
calling the ethermintd testnet
command. This outputs a handful of files in the
./build
directory:
Each ./build/nodeN
directory is mounted to the /ethermintd
directory in each container.
# Logging
In order to see the logs of a particular node you can use the following command:
The logs for the daemon will look like:
You can disregard the Can't add peer's address to addrbook
warning. As long as the blocks are
being produced and the app hashes are the same for each node, there should not be any issues.
Whereas the logs for the REST & RPC server would look like:
# Follow Logs
You can also watch logs as they are produced via Docker with the --follow
(-f
) flag, for
example:
# Interact With the Testnet
# Ethereum JSON RPC & Websocket Ports
To interact with the testnet via WebSockets or RPC/API, you will send your request to the corresponding ports:
Eth JSON-RPC | Eth WS |
---|---|
8545 | 8546 |
You can send a curl command such as:
The IP address will be the public IP of the docker container.
Additional instructions on how to interact with the WebSocket can be found on the events documentation.
# Keys & Accounts
To interact with ethermintcli
and start querying state or creating txs, you use the
ethermintcli
directory of any given node as your home
, for example:
Now that accounts exists, you may create new accounts and send those accounts funds!
Note: Each node's seed is located at ./build/nodeN/ethermintcli/key_seed.json
and can be restored to the CLI using the ethermintcli keys add --restore
command
# 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:
# Multi-node, Public, Manual Testnet
If you are looking to connect to a persistent public testnet. You will need to manually configure your node.
# Genesis and Seeds
# Copy the Genesis File
If you want to start a network from scratch, you will need to start the genesis procedure by creating a genesis.json
and submit + collect the genesis transactions from the validators.
If you want to connect to an existing testnet, fetch the testnet's genesis.json
file and copy it into the ethermintd
's config directory (i.e $HOME/.ethermintd/config/genesis.json
).
Then verify the correctness of the genesis configuration file:
# Add Seed Nodes
Your node needs to know how to find peers. You'll need to add healthy seed nodes to $HOME/.ethermintd/config/config.toml
. If those seeds aren't working, you can find more seeds and persistent peers on an existing explorer.
For more information on seeds and peers, you can the Tendermint P2P documentation.
# Start testnet
The final step is to start the nodes. Once enough voting power (+2/3) from the genesis validators is up-and-running, the testnet will start producing blocks.
# Next
Learn about how to setup a validator node on Ethermint