Configuring Networking for hc run

hc run uses mock networking by default and therefore doesn't talk to any other nodes.

In order to have hc run spawn a real network instance, start it with the --networked option:

hc run --networked

You should see something like this:

Network spawned with bindings:
     - ipc: wss://
     - p2p: ["wss://"]

Starting A Second Node

Starting up a second node is a little bit more work:

Step 1

Set the HC_N3H_BOOTSTRAP_NODE environment variable to the external p2p bound address listed by the first node. Copy-paste it from the string from the terminal log of the first node, the one that starts with "/ip4/192.168".

Step 2

Specify a different agent id than the first node, by setting the HC_AGENT environment variable. Since the first agent by default will be testAgent, testAgent2 is suitable.

Step 3

Specify a different port than the first node to run on. Since the port for the first node by default will be 8888, 8889 is suitable.

Running the command could look like this:

HC_AGENT=testAgent2 HC_N3H_BOOTSTRAP_NODE=wss:// hc run --port 8889

In the terminal logs that follow, you should see:

(libp2p) [i] QmUmUF..V71C new peer QmeDpQLchA9xeLDJ2jyXBwpe1JaQhFRrnWC2JfyyET2AAM
(libp2p) [i] QmUmUF..V71C found QmeDpQLchA9xeLDJ2jyXBwpe1JaQhFRrnWC2JfyyET2AAM in 14 ms
(libp2p) [i] QmUmUF..V71C ping round trip 37 ms
(libp2p) [i] QmUmUF..V71C got ping, sending pong

This means that the nodes are able to communicate! Watch the logs for gossip, as you take actions (that alter the source chain) in either node.

suggest an edit