Creating a Smart Chain on a Single Node
Introduction
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.
Tutorial Prerequisites
Indexchain Smart Chain software installed on a compatible machine
Launch the First daemon
Select the desired Antara customization parameters.
Link to Antara Customization Parameters
For this example, we use simple configurations.
Command
Response (truncated)
Search for the part of the response that begins with this string: >>>>>>>>>
The default p2p and rpc ports of our chain are 14165
and 14166
respectively.
Test komodo-cli
To interact with this first daemon, use a komodo-cli
command as follows.
Create a Data Directory for the Second Daemon
Create a directory on your machine for the second daemon.
In this guide, we use a directory named coinData
in the Home directory:
Create the data directory for the second daemon.
Copy the .conf
file created for the first daemon to this new data directory.
Change the values of rpcuser
, rpcpassword
, and rpcport
in the file ~/coinData/HELLOWORLD/HELLOWORLD.conf
.
The HELLOWORLD.CONF File
(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.
The value of port should be different from the value of the p2p port for the first daemon.
Launch the Second 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.
::: tip
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:
After launching the second daemon, calling getinfo
to either of the daemons should report "connections":1
.
Using curl
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.
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 First Daemon's .conf File
Source the Second Daemon's .conf File
Last updated
Was this helpful?