How to setup a Nethermind only Spaceneth based chain
Spaceneth private network setup looks very similar to the above Clique setup. However, there are few major differences and will be described below.

Prerequisites

  • Linux bash shell
  • Docker-compose
  • Docker
  • jq
  • Nethermind.Cli
1
sudo apt-get install -y docker-compose docker.io jq
Copied!

Setup

In this setup we will create a private network of 3 Nethermind nodes running a simple testing NethDev consensus algorithm.
  • create separate directory where we will store all files
1
mkdir private-networking
2
cd private-networking
Copied!
  • create folders for each node and genesis
1
mkdir node_1 node_2 node_3 genesis
Copied!
  • download chainspec file with spaceneth engine and place it in genesis folder.
1
wget https://raw.githubusercontent.com/NethermindEth/nethermind/master/src/Nethermind/Chains/spaceneth.json
2
cp spaceneth.json genesis/spaceneth.json
Copied!
  • create subfolders in each node folder
1
mkdir node_1/configs node_1/staticNodes node_2/configs node_2/staticNodes node_3/configs node_3/staticNodes
Copied!
  • create a static-nodes.json file and place it in node_1/staticNodes subfolders (do this for node_2 and node_3 as well)
1
cat <<EOF > node_1/staticNodes/static-nodes.json
2
[
3
4
]
5
EOF
Copied!
  • create config.cfg file and place it in node_1/configs subfolders (do this for node_2 and node_3 as well)
1
cat <<EOF > node_1/configs/config.cfg
2
{
3
"Init": {
4
"WebSocketsEnabled": false,
5
"StoreReceipts" : true,
6
"EnableUnsecuredDevWallet": true,
7
"IsMining": true,
8
"ChainSpecPath": "/config/genesis/spaceneth.json",
9
"BaseDbPath": "nethermind_db/spaceneth",
10
"LogFileName": "spaceneth.logs.txt",
11
"StaticNodesPath": "Data/static-nodes.json"
12
},
13
"Network": {
14
"DiscoveryPort": 30300,
15
"P2PPort": 30300,
16
"LocalIp": "10.5.0.2",
17
"ExternalIp": "10.5.0.2"
18
},
19
"JsonRpc": {
20
"Enabled": true,
21
"Host": "10.5.0.2",
22
"Port": 8545
23
}
24
}
25
EOF
Copied!
For each node you will need to change following items in configuration:
  • LocalIp, ExternalIp and Host should have the same value and be incremented for each node e.g. 10.5.0.3, 10.5.0.4 and so on and so forth.
Could not load image
  • copy docker-compose file and place it in working directory
1
version: "3.5"
2
services:
3
4
node_1:
5
image: nethermind/nethermind
6
command: --config config
7
volumes:
8
- ./genesis:/config/genesis
9
- ./node_1/configs/config.cfg:/nethermind/configs/config.cfg
10
- ./node_1/staticNodes/static-nodes.json:/nethermind/Data/static-nodes.json
11
- ./node_1/db/spaceneth:/nethermind/nethermind_db/spaceneth
12
- ./node_1/keystore:/nethermind/keystore
13
ports:
14
- 0.0.0.0:8547:8545
15
networks:
16
vpcbr:
17
ipv4_address: 10.5.0.2
18
19
node_2:
20
image: nethermind/nethermind
21
command: --config config
22
volumes:
23
- ./genesis:/config/genesis
24
- ./node_2/configs/config.cfg:/nethermind/configs/config.cfg
25
- ./node_2/staticNodes/static-nodes.json:/nethermind/Data/static-nodes.json
26
- ./node_2/db/spaceneth:/nethermind/nethermind_db/spaceneth
27
- ./node_2/keystore:/nethermind/keystore
28
ports:
29
- 0.0.0.0:8548:8545
30
networks:
31
vpcbr:
32
ipv4_address: 10.5.0.3
33
34
node_3:
35
image: nethermind/nethermind
36
command: --config config
37
volumes:
38
- ./genesis:/config/genesis
39
- ./node_3/configs/config.cfg:/nethermind/configs/config.cfg
40
- ./node_3/staticNodes/static-nodes.json:/nethermind/Data/static-nodes.json
41
- ./node_3/db/spaceneth:/nethermind/nethermind_db/spaceneth
42
- ./node_3/keystore:/nethermind/keystore
43
ports:
44
- 0.0.0.0:8549:8545
45
networks:
46
vpcbr:
47
ipv4_address: 10.5.0.4
48
49
networks:
50
vpcbr:
51
driver: bridge
52
ipam:
53
config:
54
- subnet: 10.5.0.0/16
Copied!
  • run each node separately so that we can copy Enode for each node, we will use them later
1
docker-compose run node_1
Copied!
Stop the node when Nethermind initialization completes Ctrl +C. Copy This node values to a text file. Continue with node_2 and node_3.
Could not load image
You can use Nethermind.Cli to fetch these values from nodes by executing the following. Nethermind.Cli can be found in packages on Github Releases or Download Page.
1
node.switch("http://localhost:8547")
2
node.enode
Copied!
  • the file should look similar to this:
1
STATIC_NODE_1="enode://2281549869465d98e90cebc45e1d6834a01465a990add7bcf07a49287e7e66b50[email protected]10.5.0.2:30300"
2
STATIC_NODE_2="enode://37878ec16a5ed87c9c80b4648e5428f5c768eddd79483be118319c49d11c4e535[email protected]10.5.0.3:30300"
3
STATIC_NODE_3="enode://6067f06d84c207e6233dacf1f3ef961bd7231f71d5425cbaf843cf19cfd5f7e13[email protected]10.5.0.4:30300"
Copied!
  • copy & paste above variables into your terminal
  • for each node modify previously created empty static-nodes.json files by appending Enodes to them
1
cat <<EOF > node_1/staticNodes/static-nodes.json
2
[
3
"$STATIC_NODE_1",
4
"$STATIC_NODE_2",
5
"$STATIC_NODE_3"
6
]
7
EOF
Copied!
Could not load image
  • remove databases for each node
1
sudo rm -rf node_1/db/spaceneth node_2/db/spaceneth node_3/db/spaceneth
Copied!
  • run docker-compose file
1
docker-compose up
Copied!
You should see the private network working. We now need to send transactions in order to start producing blocks.
  • run Nethermind.Cli
  • run node.switch("http://localhost:8547")
  • run personal.listAccounts
  • create new account personal.newAccount("test")
Could not load image
  • re-run personal.listAccounts and copy your account address
  • trigger blocks producing by sending transaction using eth_sendTransactionJSON RPC method or Nethermind.Cli. Change from property to your account address
1
curl --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{
2
"from": "0x89892f2c746d98cf270ff2a76672e493d9731c24",
3
"to": "0xe1ab8145f7e55dc933d51a18c793f901a3a0b276",
4
"gas": "0x76c0",
5
"gasPrice": "0x9184e72a000",
6
"value": "0x9184e72a",
7
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
8
}],"id":0}' -H "Content-Type: application/json" -X POST localhost:8547
Copied!
Could not load image
Copy link