How to create an environment variable to use cardano-cli with Daedalus Wallet

Christopher Huxley   ยท   December 5, 2021

Why do this?

If you want to use the cardano-cli and cardano-wallet tools that came with Daedalus Wallet, you'll need to create an environment variable.

Linux

In your shell, type the following:

export CARDANO_NODE_SOCKET_PATH="$HOME/cardano/testnet-db/node.socket"

You can add that line to the end of ~/.bashrc (Bash shell) or ~/.zshrc (ZSH shell) so you don't have to type it every time.

Windows

Windows uses a named pipe rather than a socket.

As of December 2021, there isn't an easy way (that I know of) to obtain the named pipe. Each time Daedalus Wallet updates to a new version, the name of the pipe changes. This means you'll need to update your environment variable whenever there's a new version of the Daedalus Wallet.

Get the pipe name

Use any of the following methods to find the Cardano pipe name. It should look something like \\.\pipe\cardano-node-mainnet.32564.0

Method 1: Command line:

wmic process get commandline | findstr pipe\cardano

Method 2: PowerShell

get-childitem \\.\pipe\ | findstr cardano

Method 3: ProcessExplorer - Search for cardano-wallet.exe and look at its commandline arguments

Create an environment variable

After that, create a new environment variable. From the Start menu, search for this: Edit environment variables for your account. Create a new one for "me" (the top section):

  • Variable name: CARDANO_NODE_SOCKET_PATH
  • Variable value: \\.\pipe\cardano-node-mainnet.32564.0

See if it works

Open a new command prompt and type this:

cd "C:\Program Files\Daedalus Mainnet"
cardano-cli query tip --mainnet

You should see something like this:

{
    "hash": "a3a93043d015e9bb089b1a90d59b1922dffb9684b5c64a61426b6134e348123d",
    "block": 6589745,
    "slot": 47163888,
    "syncProgress": "100.00",
    "era": "Alonzo",
    "epoch": 306
}

Troubleshooting

If you tried to run one of the following commands to set the environment variable from the commandline instead of setting it the way described above, you got an error. I'm including this for those searching for a solution.

    # you may have tried this
    set CARDANO_NODE_SOCKET_PATH="\\.\pipe\cardano-node-mainnet.32564.0"
    # or maybe you tried this (escaping the backslashes)
    set CARDANO_NODE_SOCKET_PATH="\\\\.\\pipe\\cardano-node-mainnet.32564.0"

    cardano-cli query tip --mainnet

This would give the following error: cardano-cli: CreateFile "\"\\\\.\\pipe\\cardano-node-mainnet.32564.0\"": invalid argument (The filename, directory name, or volume label syntax is incorrect.)

Comments