Skip to main content

Multi Node

Automated Localnet with Docker

Build & Start

Build and start a testnet with 4 nodes.

make localnet-start

The ports for each node are found in the following table:

Node IDP2P PortREST/Ethereum JSON-RPC PortWebsocket Port
node02665685458546
node12665985478548
node22666185498550
node32666385518552

To update the binaries, you need to rebuild and restart the node

To start the container and create the network using Docker Compose, you can use the following command:

...
Creating network "treasurenet_localnet" with driver "bridge"
Creating node0 ... done
Creating node2 ... done
Creating node1 ... done
Creating node3 ... done

Stop Localnet

make localnet-stop

Logging

# node0:daemon logs
docker exec node0 tail treasurenetd.log

Interact with the Localnet

Ethereum JSON-RPC 和 Websocket 接口

To interact with testnet via Websocket or RPC/API, you need to send a request to the appropriate port:

You can try to send a request via curl:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" 127.0.0.1:8545

Key and Accounts

To interact with treasurenetd and start querying status or creating transactions, you can use the treasurenetd directory of any given node as your home directory:

treasurenetd keys list --home ./build/node0/treasurenetd