Introduction
The Celo command-line interface (CLI) is a powerful tool that enables developers to interact with the Celo network. This guide will provide an introduction to the Celo CLI, offering insights into installation, setting up accounts, and executing transactions.
What is Celo CLI?
The Celo CLI, short for Command Line Interface, is a software package that allows developers to interact directly with the Celo network. Through the CLI, developers can execute commands that facilitate various interactions with the network such as creating accounts, managing Celo Gold (cGLD) and Celo Dollar (cUSD) balances, deploying smart contracts, making transactions, and more.
Installation
Before installing Celo CLI, you need to install Node.js and npm (Node Package Manager). After setting up Node.js and npm, you can install Celo CLI using npm:
npm install -g @celo/celocli
It’s necessary to use node version 12, you can change this using the command, then verify the version being used
nvm install 12.0.0
nvm use 12.0.0
This will install Celo CLI globally on your system, allowing you to use it in any directory.
Setting Up an Account
Once you have installed the Celo CLI, you can set up a new account. To create a new account, use the account:new
command. This command generates a new private/public key pair and prints the account address:
celocli account:new
After running this command, you will get an output similar to this:
account: {
address: '0x5409ED021D9299bf6814279A6A1411A7e866A631',
privateKey: '0x1a8bfD625e7B6d6eA2443dE74E7120748fe36BD6aF1a274f16432a0672604F09',
publicKey: '0x0406cc344d288d76c0629972813474a916e8080bb2e9fa2e65af585da4700248dc11899843db6ba4680ab1c80746a1e20aa0aa2aa8e9d43e8108a13d75222663cd',
}
Note: Store your private key in a secure location. If you lose access to your private key, you will lose access to your account.
Checking Account Balance
To check the balance of a Celo account, you can use the account:balance
command. Replace address
with the actual address of your account:
celocli account:balance address
Sending Transactions
To send transactions on the Celo network, you use the transfer:celo
command. The following command transfers 0.0001 cGLD from one account to another:
celocli transfer:celo --from <accountAddress> --to <addressOfChoice> --value <valueInCeloWei> --privateKey <privateKey> --node https://forno.celo.org
In this command, replace address_from
with the sender’s address and address_to
with the recipient’s address. The value
parameter specifies the amount to transfer, in wei. 1e18 wei equals 1 CELO.
Other Commands
Here are various commands available on the Celo Blockchain CLI. Please note that these commands assume that you have the Celo CLI installed and set up correctly on your local machine.
-
Account Management Commands:
celocli account:balance
- This command is used to check the balance of a Celo account.celocli account:new
- This command is used to create a new Celo account.celocli account:unlock
- This command unlocks an account, allowing it to sign transactions. -
Transaction Management Commands:
celocli transfer:celo
- This command is used to transfer CELO between accounts.celocli transfer:usd
- This command is used to transfer Celo Dollars (cUSD) between accounts.celocli transfer:fromledger
- This command is used to transfer funds from a Ledger hardware wallet. -
Network Information Commands:
celocli network:parameters
- This command provides the current network parameters.celocli network:status
- This command provides information about the status of the network. -
Validator and Validator Group Commands:
celocli validator:status
- This command provides information about a validator’s status.celocli validator:show
- This command displays information about a specific validator.celocli validatorgroup:show
- This command shows information about a validator group.celocli validatorgroup:member
- This command lists the validators in a validator group.
Please note that this is a non-exhaustive list, and more commands are available. The full list of commands and their respective options can be found in the Celo CLI documentation. It’s also important to note that as the Celo project evolves, new commands might be introduced and old ones deprecated. Always refer to the most recent documentation when using the Celo CLI.
Remember to exercise caution when executing these commands, particularly when transferring assets or interacting with smart contracts, as mistakes can lead to loss of funds. As always, it’s recommended to have a good understanding of how blockchain technology and CLI tools work before interacting with the Celo network at this level.
Conclusion
The Celo CLI is a comprehensive tool for interacting with the Celo network. Through its intuitive command structure and rich feature set, developers can create accounts, manage balances, and perform transactions with ease. While this guide offers an introduction to the Celo CLI, developers are encouraged to explore the full range of commands and capabilities that the CLI offers.
About Us
Joel Obafemi
A marketer, copywriter, and collab manager for web3 brands. You can connect with me on LinkedIn.
Reference
Celo Documentation
Celo CLI account
Celo CLI: A Practical Guide to Energize your Celo Toolkit