Using a remote node
In order to interrogate a node with cardano-cli and submit transactions to it with cardano-cli, cardano-cli needs to connect to its socket file.
It is possible to use socat
to connect to the socket of a remote node. For that, 2 things must be done:
on the server running the node, where the socket file is, the following
socat
command must be executed:socat TCP-LISTEN:2010,reuseaddr,fork UNIX-connect:/opt/cardano/cnode/db/node.socket
This command will create a TCP socket on the port 2010 (the port can be any available port), and will connect it to the cardano-node socket file (the path/opt/cardano/cnode/db/node.socket
must be adjusted to point to the existing socket file).on the client, where the
cardano-cli
commands will be executed, the following command must executed:socat UNIX-LISTEN:/run/cardano-node.socket,fork,reuseaddr,unlink-early,user=<username>,group=<group>,mode=755 TCP:<server_ip_address>:2010
The/run/cardano-node.socket
is where the local socket file will be created. The <username> and <group> must be replaced with the username and the group of the user who will run the cardano-cli commands, the<server_ip_address>
the must be the server's ip address or hostname, and the port 2010 must be the same port configured on the server.
After doing this, the CARDANO_NODE_SOCKET_PATH
environment variable must be set to the /run/cardano-node.socket
file (the name that was used in the second command), and then cardano-cli can be used to interrogate the cardano-node.
Last updated