Configuring Cardano CLI
Make sure you have a cardano node running on testnet, and it's synced with other nodes. If you don't have one, check the previous chapter to set it up.
In this tutorial, I'm using cardano-cli 1.26.1, if you are using other version, the commands might be different.
First, let's create a cli-workspace/testnet directory as our workspace, you can create this directory anywhere.
1
mkdir -p cli-workspace/testnet
2
cd cli-workspace/testnet
Copied!
Create a file to store some environment configurations.
1
touch env.sh
Copied!
Add following lines to env.sh:
1
export CARDANO_NODE_PATH=path_to_your_cardano_node_directory
2
3
alias cardano-cli=$CARDANO_NODE_PATH/cardano-cli
4
5
export CARDANO_NODE_SOCKET_PATH=$CARDANO_NODE_PATH/node-ipc/testnet/node.socket
6
7
export TESTNET_MAGIC=1097911063
Copied!
  • The path_to_your_cardano_node_directory is the directory where cardano-cli executable is located.
  • If you were following the last chapter to set up cardano node, your node socket path should be $CARDANO_NODE_PATH/node-ipc/testnet/node.socket.
  • The testnet magic can be found in testnet-shelley-genesis.json file in networkMagic field, if you were following the last chapter to set up your cardano node, the networkMagic should be 1097911063.
To load configurations in current terminal, run:
1
source env.sh
Copied!
Note that everytime you open a new console, you need to run source env.sh command.
Now, make sure your cardano node is running at background, then let's test if cardano-cli is working:
1
cardano-cli query protocol-parameters --testnet-magic $TESTNET_MAGIC
Copied!
if you see console output like this, your cardano-cli should be configured correctly:
1
{
2
"txFeePerByte": 44,
3
"minUTxOValue": 1000000,
4
"stakePoolDeposit": 500000000,
5
"decentralization": 0,
6
"poolRetireMaxEpoch": 18,
7
"extraPraosEntropy": null,
8
"stakePoolTargetNum": 500,
9
"maxBlockBodySize": 65536,
10
"maxTxSize": 16384,
11
"treasuryCut": 0.2,
12
"minPoolCost": 340000000,
13
"maxBlockHeaderSize": 1100,
14
"protocolVersion": {
15
"minor": 0,
16
"major": 4
17
},
18
"txFeeFixed": 155381,
19
"stakeAddressDeposit": 2000000,
20
"monetaryExpansion": 3.0e-3,
21
"poolPledgeInfluence": 0.3
22
}
Copied!
Copy link