Cardano CLI Guru provides a wealth of convenient utility scripts to simplify the use of cardano-cli, as well as a guided tutorial to walk you through various cardano-cli operations.
This utility uses direnv to set and unset various environment variables whenever you navigate in and out of the cardano-cli-guru directory, allowing for more convenient use of cardano-cli without polluting your ~/.bashrc or other dotfiles with additional variables. These local variables can be adjusted to your needs by modifying the contents of the .env file that is automatically created when you allow direnv to run in the directory the first time.
-
Install
cardano-nodeandcardano-cli.- You can use the Cardano EZ-Installer to easily install both applications via Nix and automatically configure your node for use with all three networks (
preprodandpreviewtestnets,mainnet).
- You can use the Cardano EZ-Installer to easily install both applications via Nix and automatically configure your node for use with all three networks (
-
Install the
direnvutility.-
If you have Nix installed, the easiest way to do this is via the following Nix command:
nix profile install nixpkgs#direnv
NOTE: this command requires the
experimental-featuresnix-commandandflakesto be enabled in your/etc/nix/nix.conffile:experimental-features = nix-command flakesYou'll need to restart the
nix-daemonafter making changes tonix.conf:Linux:
sudo systemctl restart nix-daemon
MacOS:
sudo launchctl stop org.nixos.nix-daemon sudo launchctl start org.nixos.nix-daemon
-
-
Clone this repository in your terminal and navigate to the
cardano-cli-gurudirectory:git clone https://github.com/iburzynski/cardano-cli-guru cd cardano-cli-guru -
You will see the following error message:
direnv: error /home/your-username/path-to-cardano-cli-guru/.envrc is blocked. Run `direnv allow` to approve its contentThis is a security measure, since
.envrcfiles can run arbitrary shell commands. Make sure you always trust the author of a project and inspect the contents of its.envrcfile before runningdirenv allow.When you're ready, enter
direnv allowto approve the content:direnv allow
-
Adjust
.envvariables as needed.-
When you allow
direnvto run in thecardano-cli-gurudirectory, a.envfile is automatically created containing various environment variables with default settings. These variables are used bycardano-cliand the various utility scripts provided bycardano-cli-guruand can be adjusted according to your needs. -
The
CARDANO_NODE_NETWORK_IDvariable tellscardano-cliwhich network your node is currently using. By default this is set to2forpreviewtestnet. Change this value to1if you want your node to run on thepreprodtestnet, or tomainnetfor the mainnet. -
Two variables are defined for interacting with Blockfrost, which is used to retrieve transaction metadata in the Tutorial. You can replace the placeholder value for either
BLOCKFROST_PROJECT_ID_PREPRODorBLOCKFROST_PROJECT_ID_PREVIEWwith your Blockfrost Project ID, depending on which network you are using in your Blockfrost project. -
The remaining
*PATHvariables are set to existing subdirectories ofcardano-cli-guru, and tell the utility scripts where to store the various output files of the utility scripts. You can change these to point to different directories if you'd like your output files to be stored somewhere else, although it is easier to keep the default locations.NOTE: if you wish to change any of the
*PATHvariables, make sure your filepaths are defined relative to thecardano-cli-gurudirectory, or use absolute filepaths. -
If you changed any values in
.env, rundirenv allowagain in thecardano-cli-gurudirectory sodirenvupdates the variables.NOTE: You must run
direnv allowwhenever you modify.env, or the variables will still be set to their previous values in the environment.
-
-
Start
cardano-node.-
You're now ready to start your node and begin using
cardano-cli. In a separate terminal session, run the appropriate command to startcardano-nodeon your desired network (i.e.preprod-nodeorpreview-nodeif you installed using Cardano EZ-Installer).NOTE: Make sure the value of
CARDANO_NODE_NETWORK_IDin the.envfile corresponds to the network you are running! -
It's normal for the node to encounter occasional errors, which it will recover from and continue running. To tell if your node is working properly, look for
Chain extendedlog entries with the following format:Chain extended, new tip: c472036b83c119b875e3fc230435b741598677ffa45ea3ad8ad9cda3f70a872d at slot 12227931
-
After giving the node a little time to boot up, try running the
tipcommand from thecardano-cli-gurudirectory. You should see output informing you of the current slot number and the percentage that your node is synced. Once your node is 100% synced you can begin using the other utility scripts to interact with the blockchain.$ tip { "block": 546242, "epoch": 141, "era": "Babbage", "hash": "7ee471e26ed927ae463d386cdd322fd7f3afb18d0fef462255ce2a2f221d7112", "slot": 12227857, "syncProgress": "100.00" } -
When you are finished, make sure to properly close the node connection by typing
CTRL + cin the terminal session where it's running. If you close the terminal without doing this, the socket will remain open and you won't be able to start the node again unless you manually kill the associated process or restart your system!
-
At this point you're ready to begin using cardano-cli with Cardano CLI Guru!
Cardano CLI Guru provides a tutorial in cardano-cli-guru/tutorial, with guided exercises for building/submitting various types of transactions using cardano-cli. The tutorial begins with the simplest possible transaction and progresses through increasingly complex examples.
Many prewritten utility scripts have been provided to make the process less laborious, but you should always inspect the contents of these scripts before using them to understand the structure of the underlying cardano-cli commands.
For example, if we inspect the contents of the tip script at cardano-cli-guru/scripts/tip we'll see the following:
# cardano-cli-guru/scripts/tip
cardano-cli query tipThis script uses cardano-cli's query command to query information about the tip of the chain.