How to create a temporary NGIN network

This is the tutorial material for dev building a temporary NGIN network through ngcore’s regression testnet flag.

Ready

Before we start, we should create two different folder to keep the chain data.

I will suggest using --in-mem flag which can reach the same goal.

If you dislike that, for example, you can create ./dataFolder1 and dataFolder2.
On the following ngcore command, you should add --db-folder dataFolder1 for the first node
and --db-folder dataFolder2 for the second one

Node #0

let we start a regression testnet ngcore node with --reg-testnet only first.

1
./ngcore --reg-testnet --db-folder ./env/1 --p2p-key ./env/1.p2pkey 

The node will serve its p2p service on 52520 and rpc service on 52521.

Write down this node’s p2p address like 16Uiu2HAmL6ojX5jgxJsoo55suHxM8HocaLuMx4uLSfHpER9rTYtJ , which will be used in the connecting step.

Node #1

Now we need to start another one on different port

1
./ngcore --reg-testnet --db-folder ./env/2 --p2p-key ./env/2.p2pkey --p2p-port 62620 --rpc-port 62621

The node will serve its p2p service on 62620 and rpc service on 62621.

Connect

To build a small network, we should use rpc command to manually connect them.

1
curl -d '{"id": 1, "method": "addPeer", "params": {"peerMultiAddr": "/ip4/127.0.0.1/tcp/52520/p2p/16Uiu2HAmL6ojX5jgxJsoo55suHxM8HocaLuMx4uLSfHpER9rTYtJ"} }' http://127.0.0.1:62621

16Uiu2HAmL6ojX5jgxJsoo55suHxM8HocaLuMx4uLSfHpER9rTYtJ is the p2p address of node #0 in my machine. You should replace it with yours.

Startup

Finally, you should let one of your node start mining, to import blocks into your chain.

1
curl -d '{"id": 1, "method": "switchMining", "params": {"mode": "on"} }' http://127.0.0.1:62621