Commonly used dfx commands for beginners

Commonly used dfx commands for beginners

A beginner's cheat sheet

Using commands in the terminal to launch and manage your programs becomes a need when working in a development environment. The terminal offers a potent user interface for working with your project-related development tools and running various commands.

The terminal can be used by developers to deploy their applications, manage dependencies, run tests, and compile their code. You may automate these processes and improve your productivity by utilizing commands in the terminal, which will make it simpler to create and maintain your project.

In this article, we will learn about the most commonly used DFX commands for beginners.

To check the dfx version installed on the local computer

dfx --version

Get help on different dfx commands

dfx --help

DEPLOYMENT

Start a local replica of the IC and a web server for the current project.

dfx start

Create a new project boilerplate.

dfx new <PROJECT_NAME>

Upgrade the dfx version to the latest one

dfx upgrade

IDENTITY

Create a new identity to use

dfx identity new <IDENTITY_NAME>

Get a list of all the identities created

dfx identity list

Switch to a new identity

dfx identity use <IDENTITY_NAME>

Remove an identity from the list

dfx identity remove <IDENTITY_NAME>

Show the name of the current identity

dfx identity whoami

Rename an existing identity

dfx identity rename <FROM> <TO>

CANISTER

Create a new empty canister

dfx canister create <CANISTER_NAME>

Access the canister id

dfx canister id <CANISTER_NAME>

Stop a running canister

dfx canister stop <CANISTER_NAME>

Delete the stopped canister

dfx canister delete <CANISTER_NAME>

Install compiled code in a canister

dfx canister install <CANISTER_NAME>

Create all canisters in the project at once

dfx canister create --all

Compile, build, and install the code in all the canisters at once.

dfx deploy

Deploy a canister with initial cycles

dfx deploy --with-cycles <AMOUNT>

WALLET

Get the cycle balance of the wallet associated with the identity

dfx wallet balance

Set the name of the cycles wallet

dfx wallet set-name <WALLET_NAME>

Set the name of the cycles wallet associated with the identity

dfx wallet name

Send cycles to another wallet

dfx wallet send <DESTINATION> <AMOUNT>

Stop the local network replica

dfx stop

Conclusion

In this article, you have learned about the most used commands in the terminal when building projects on the Internet Computer. The list is not final as there are many other commands. Feel free to put other suggestions in the comment section that should be included. I will surely add them to the list.

Thank you for taking the time to read this article, Let's connect on Twitter.