dfx
The DFINITY command-line execution environment (dfx) is the primary tool for creating, deploying, and managing the applications you develop for the Internet Computer blockchain.
Use the dfx parent command with flags and subcommands to specify the operations you want to perform with or without optional arguments.
Flags
You can use the following optional flags with the dfx parent command or with any of the dfx subcommands.
| Flag | Description |
|---|---|
|
Displays usage information. |
|
Suppresses informational messages. |
|
Displays detailed information about operations. |
|
Displays version information. |
Options
You can use the following options with the dfx command.
| Option | Description |
|---|---|
|
Specifies the user identity to use when running a command. |
|
Writes log file messages to the specified log file name if you use the |
|
Specifies the logging mode to use. + You can set the log mode to one of the following: - - - The default logging mode is |
Subcommands
Use the following subcommands to specify the operation you want to perform or to view usage information for a specific command.
For reference information and examples, select an appropriate subcommand.
| Command | Description |
|---|---|
Starts the bootstrap server you want to use to serve front-end assets for your project. |
|
Builds canister output from the source code in your project. |
|
Manages the |
|
Manages canisters deployed on a network replica. |
|
Sets or changes configuration options for your current project. |
|
Deploys all or a specific canister from the code in your project. By default, all canisters are deployed. |
|
Displays usage information for a specified subcommand. |
|
Enables you to create and manage the identities used to communicate with the Internet Computer network. |
|
Enables you to interact with accounts in the ledger canister running on the Internet Computer. |
|
Creates a new project. |
|
Sends a response request to a specified Internet Computer network to determine network connectivity. If the connection is successful, the Internet Computer replies with its status. |
|
Starts a local network replica process. |
|
Starts the local network replica and a web server for the current project. |
|
Stops the local network replica. |
|
Upgrades the version of |
|
Enables you to manage cycles, controllers, custodians, and addresses for the default cycles wallet associated with the currently-selected identity. |
Examples
You can use the dfx parent command to display usage information or version information.
For example, to display information about the version of dfx you currently have installed, you can run the following command:
dfx --version
To view usage information for a specific subcommand, specify the subcommand and the --help flag.
For example, to see usage information for dfx build, you can run the following command:
dfx build --help
Using logging options
You can use the --verbose and --quiet flags to increment or decrement the logging level.
If you don’t specify any logging level, CRITICAL, ERROR, WARNING, and INFO messages are logged by default.
Specifying one verbose flag (-v) increases the log level to include DEBUG messages.
Specifying two verbose flags (-vv)increases the logging level to include both DEBUG and TRACE messages.
Adding a --quiet flag decreases the logging level.
For example, to remove all messages, you can run a command similar the following:
dfx -qqqq build
Keep in mind that using TRACE level logging (--vv) generates a lot of log messages that can affect performance and should only be used when required for troubleshooting or analysis.
To output log messages to a file named newlog.txt and display the messages on your terminal when creating a new project, you can run a command similar to the following:
dfx --log tee --logfile newlog.txt new hello_world
Specifying a user identity
If you create user identities with the dfx identity new command, you can then use the --identity comment-line option to change the user context when running other dfx commands.
In the most common use case, you use the --identity option to call specific canister functions to test access controls for specific operations.
For example, you might want to test whether the devops user identity can call the modify_profile function for the accounts canister by running the following command:
dfx --identity devops canister call accounts modify_profile '("Kris Smith")'