On this page

latest contributor to this doc

Last Edit:


Creating a Smart Chain on a Single Node

Under most circumstances, a developer should use two separate nodes to set up and create a Smart Chain.

However, occasionally a developer may need to create a Smart Chain on a single node. This can be achieved using the testnode runtime parameter. The following tutorial is only neccesary if the developer desires to run two instances of the daemon on the same server.

In this situation, the developer may create a Smart Chain by running two daemons with slightly different configurations on the same node.

Select the desired Antara customization parameters.

Link to Antara Customization Parameters

For this example, we use simple configurations.

./komodod -ac_name=HELLOWORLD -ac_supply=777777

If you want the Smart Chain to have Antara Modules enabled, please include the -ac_cc parameter with the required value in your launch parameters on both the daemons.

Search for the part of the response that begins with this string: >>>>>>>>>

>>>>>>>>>> HELLOWORLD: p2p.14165 rpc.14166 magic.01362c2a 20327466 777777 coins

The default p2p and rpc ports of our chain are 14165 and 14166 respectively.

To interact with this first daemon, use a komodo-cli command as follows.

./komodo-cli -ac_name=HELLOWORLD getinfo

Create a directory on your machine for the second daemon.

In this guide, we use a directory named coinData in the Home directory:

mkdir ~/coinData

Create the data directory for the second daemon.

mkdir ~/coinData/HELLOWORLD

Copy the .conf file created for the first daemon to this new data directory.

cp ~/.komodo/HELLOWORLD/HELLOWORLD.conf ~/coinData/HELLOWORLD/

Change the values of rpcuser, rpcpassword, and rpcport in the file ~/coinData/HELLOWORLD/HELLOWORLD.conf.

... (ommitted) ...

(Change all values shown above on the right side of the = side. In all values above, the chosen values must be different from the values in the first daemon's .conf file.)

Add a new line port=<choose a port number betwen 1 and 65000> to the file. This value indicates the p2pport used by the second daemon.

... (file continued) ...

The value of port should be different from the value of the p2p port for the first daemon.

When launching the second daemon, use the same Antara customization parameters as the first daemon.

However, now we specify the data directory for the daemon, as well as the p2p connection.

To accomplish this, we use the datadir and addnode common launch parameters.

./komodod -ac_name=HELLOWORLD -ac_supply=777777 -datadir=/home/<USERNAME>/coinData/HELLOWORLD -addnode=localhost

Replace <USERNAME> with the USERNAME for your local node. You can find this value by using the echo $USER command in the terminal.

To interact with the second daemon, add the datadir parameter to the komodo-cli command:

./komodo-cli -ac_name=HELLOWORLD -datadir=/home/<USERNAME>/coinData/HELLOWORLD getinfo

After launching the second daemon, calling getinfo to either of the daemons should report "connections":1.

To issue a getinfo call using curl, observe the following example.

Replace <rpcuser>, <rpcpassword>, <rpcport> with the values from the .conf file in the data directory corresponding to the daemon that needs to be queried.

curl -s --user <rpcuser>:<rpcpassword> --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getinfo", "params": []}' -H 'content-type: text/plain;'<rpcport>/

Alternatively, source the .conf file before using the curl command. Each time you desire to switch daemons, source the .conf file of your target daemon.

# Source the .conf file

source ~/.komodo/HELLOWORLD/HELLOWORLD.conf

# Execute the curl command

curl -s --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getinfo", "params": []}' -H 'content-type: text/plain;'$rpcport/
# Source the .conf file

source ~/coinData/HELLOWORLD/HELLOWORLD.conf

# Execute the curl command

curl -s --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getinfo", "params": []}' -H 'content-type: text/plain;'$rpcport/