### Run dfx quickstart Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-quickstart.mdx Execute the `dfx quickstart` command to perform initial setup or get information about your ICP balance and conversion rates. ```bash dfx quickstart ``` -------------------------------- ### Full local NNS setup and API call example Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-nns.mdx This example demonstrates a complete setup for making API calls to a local NNS. It involves stopping the dfx server, starting it clean, installing NNS canisters, importing them, and then making a canister call. ```bash dfx stop dfx start --clean --background dfx nns install dfx nns import dfx canister call --network ic nns-governance get_pending_proposals '()' ``` -------------------------------- ### Start Local Replica and Deploy Source: https://github.com/dfinity/sdk/blob/master/src/dfx/assets/project_templates/base/README.md Commands to start the local DFX replica in the background and deploy your canisters. ```bash # Starts the replica, running in the background dfx start --background # Deploys your canisters to the replica and generates your candid interface dfx deploy ``` -------------------------------- ### Basic dfx start Usage Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx The fundamental syntax for invoking the `dfx start` command with optional arguments. ```bash dfx start [option] [flag] ``` -------------------------------- ### Start Frontend Development Server Source: https://github.com/dfinity/sdk/blob/master/src/dfx/assets/project_templates/base/README.md Starts a local development server that proxies API requests to the DFX replica. ```bash npm start ``` -------------------------------- ### Install all canisters in a project Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Use this command to deploy all canisters defined in your project's `dfx.json` file. This is the most common installation method. ```bash dfx canister install --all ``` -------------------------------- ### Get help for a dfx ledger subcommand Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-ledger.mdx To view detailed usage information for a specific subcommand, append the --help flag. This example shows how to get help for the 'transfer' subcommand. ```bash dfx ledger transfer --help ``` -------------------------------- ### dfx canister install Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Use the `dfx canister install` command to install compiled code as a canister on the mainnet or the local development environment. ```APIDOC ## dfx canister install ### Description Installs compiled code as a canister on the mainnet or the local development environment. ### Basic usage ```bash dfx canister install [option] [--all | canister_name] ``` ``` -------------------------------- ### Install IC SDK via curl Source: https://github.com/dfinity/sdk/blob/master/README.md Installs the IC SDK using a curl command. This is the recommended method and adds the `dfx` binary to `/usr/local/bin`. ```bash sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)" ``` -------------------------------- ### Install Rust Source: https://github.com/dfinity/sdk/blob/master/README.md Installs Rust using the official installation script. This is a prerequisite for developing Rust projects on the IC. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Asset Canister Initialization and Upgrade Arguments Source: https://github.com/dfinity/sdk/blob/master/docs/design/asset-canister-interface.md Defines the arguments for `init` and `post_upgrade` methods, allowing configuration of permissions during canister installation or upgrade. Use `Init` for initial setup and `Upgrade` for subsequent upgrades. ```candid service: (asset_canister_args: variant { Init: record { set_permissions: opt record { prepare: vec principal; commit: vec principal; manage_permissions: vec principal; }; }; Upgrade: record { set_permissions: opt record { prepare: vec principal; commit: vec principal; manage_permissions: vec principal; }; }; }) ``` -------------------------------- ### Deploy a canister with an installation argument Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deploy.mdx Deploy the 'hello_actor_class' canister and pass a string argument '("from DFINITY")' to its installation step. The argument format depends on the canister's expected input. ```bash dfx deploy hello_actor_class --argument '("from DFINITY")' ``` -------------------------------- ### Install IC SDK using GitHub Action Source: https://github.com/dfinity/sdk/blob/master/README.md Sets up the IC SDK within a GitHub Actions workflow using the `dfinity/setup-dfx` action. ```yaml steps: - name: Install dfx uses: dfinity/setup-dfx@main ``` -------------------------------- ### Create and view SNS configuration file Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-sns.mdx This example demonstrates creating an SNS configuration file and then viewing its contents using `less` to prepare for further customization. ```bash dfx sns create less sns.yml ``` -------------------------------- ### Install Beta Version using dfxvm Source: https://github.com/dfinity/sdk/blob/master/docs/process/release.md Command to manually install a specific beta version of dfx using the dfxvm tool for testing purposes. ```bash dfxvm install 0.15.3-beta.1 ``` -------------------------------- ### Create Project with Frontend Template Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Install frontend template code using the `--frontend` flag. The default is `vanilla` if NodeJS is installed. Other options include `svelte`, `react`, `vue`, `plain-assets`, or `none` to skip. ```bash dfx new --frontend react _project_name_ ``` -------------------------------- ### Navigate and Get Help with DFX Source: https://github.com/dfinity/sdk/blob/master/src/dfx/assets/project_templates/base/README.md Navigate to your project directory and access DFX help commands. ```bash cd __project_name__/ dfx help dfx canister --help ``` -------------------------------- ### Start all canisters Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Starts all canisters configured in the `dfx.json` file, or all canisters deployed on the mainnet if `--network=ic` is specified. This is useful for bringing up an entire local development environment or managing mainnet canister states. ```bash dfx canister start --all --network=ic ``` -------------------------------- ### Bootstrap System Canisters Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx Use the `--system-canisters` flag to bootstrap the system canisters when starting the local development environment. ```bash dfx start --system-canisters ``` -------------------------------- ### Start local development environment Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx Starts the local development environment and web server processes in the current shell. You will need to open a new terminal for additional commands. ```bash dfx start ``` -------------------------------- ### Install the latest dfx version from cache Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-cache.mdx Installs the latest `dfx` version available in the local cache. This command requires no arguments. ```bash dfx cache install ``` -------------------------------- ### Example pulled.json Content Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/pull-dependencies.md This JSON file details the direct and indirect dependencies, including their Wasm hashes, initialization argument guides, and candid argument formats. It is generated by `dfx deps pull`. ```json { "canisters": { "yofga-2qaaa-aaaaa-aabsq-cai": { "dependencies": [ "yofga-2qaaa-aaaaa-aabsq-cai" ], "wasm_hash": "616af3b750c80787f5f123cf7860206db3bb352ef1efe77afcce4d3ee9f2c7ab", "wasm_hash_download": "6f053bb3d53d64409c6bddc9355eea658f3d79d510cf57c587bcc809c804bdea", "init_guide": "A natural number, e.g. 10.", "init_arg": "10", "candid_args": "(nat)", "gzip": false }, "yhgn4-myaaa-aaaaa-aabta-cai": { "name": "dep_b", "dependencies": [ "yofga-2qaaa-aaaaa-aabsq-cai" ], "wasm_hash": "5642fc8c6fcc0e975a48c87d8e5f21ad0781cb740e5230647754bde14e7f1569", "wasm_hash_download": "5642fc8c6fcc0e975a48c87d8e5f21ad0781cb740e5230647754bde14e7f1569", "init_guide": "No init arguments required", "init_arg": null, "candid_args": "()", "gzip": true }, "yahli-baaaa-aaaaa-aabtq-cai": { "name": "dep_c", "dependencies": [ "yofga-2qaaa-aaaaa-aabsq-cai" ], "wasm_hash": "6f053bb3d53d64409c6bddc9355eea658f3d79d510cf57c587bcc809c804bdea", "wasm_hash_download": "6f053bb3d53d64409c6bddc9355eea658f3d79d510cf57c587bcc809c804bdea", "init_guide": "An optional natural number, e.g. \"(opt 20)\".", "init_arg": null, "candid_args": "(opt nat)", "gzip": false } } } ``` -------------------------------- ### Get help for a dfx canister subcommand Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx To view usage information for a specific `dfx canister` subcommand, append the `--help` flag. This example shows how to get help for the `call` subcommand. ```bash dfx canister call --help ``` -------------------------------- ### Start dfx in Background Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx Use the `--background` flag to start the local development environment and web server processes in the background. The command will wait for a reply before returning control to the shell. ```bash dfx start --background ``` -------------------------------- ### Install a specific dfx version Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-envars.mdx Use DFX_VERSION to specify the SDK version during installation via the provided script. ```shell DFX_VERSION=0.10.0 sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)" ``` -------------------------------- ### Install a canister asynchronously Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Submit a canister installation request without waiting for completion. This returns a request identifier that can be used to track the status later. ```bash dfx canister install hello_world_backend --async ``` ```text 0x58d08e785445dcab4ff090463b9e8b12565a67bf436251d13e308b32b5058608 ``` -------------------------------- ### Install local NNS with system subnet Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-nns.mdx To install a local NNS, the local network must be configured with a system subnet type. Ensure the dfx server is clean and running in the background before installation. ```bash cat ~/.config/dfx/networks.json { "local": { "bind": "127.0.0.1:8080", "type": "ephemeral", "replica": { "subnet_type": "system" } } } dfx start --clean --background dfx nns install ``` -------------------------------- ### dfx canister install Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Installs compiled code in a canister. This command is used to deploy or update canister code. ```APIDOC ## dfx canister install ### Description Installs compiled code in a canister. ### Method `dfx canister install` ### Endpoint N/A (CLI command) ### Parameters #### Command Arguments - `canister_id`: The ID or name of the canister. - `wasm_path`: The path to the compiled Wasm module. #### Options - `--network`: Specifies the network to use (e.g., `ic` for mainnet, `local`). - `--mode`: The installation mode (e.g., `install`, `reinstall`, `upgrade`). ### Request Example ```bash dfx canister install my_canister --mode reinstall ./my_canister.wasm ``` ### Response #### Success Response Indicates successful installation or upgrade of the canister code. ``` -------------------------------- ### dfx cache install Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-cache.mdx Installs the latest `dfx` version currently found in the `dfx` cache. ```APIDOC ## dfx cache install Use the `dfx cache install` command to install the latest `dfx` version currently found in the `dfx` cache. ### Basic usage ```bash dfx cache install [flag] ``` ### Example ```bash dfx cache install ``` ``` -------------------------------- ### Deploy All Pull Dependencies Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/pull-dependencies.md Use `dfx deps deploy` to create and install all dependencies on the local replica. This command ensures dependencies are created with mainnet canister IDs and installed with arguments from `init.json`. ```bash > dfx deps deploy Creating canister: yofga-2qaaa-aaaaa-aabsq-cai Installing canister: yofga-2qaaa-aaaaa-aabsq-cai Creating canister: yhgn4-myaaa-aaaaa-aabta-cai (dep_b) Installing canister: yhgn4-myaaa-aaaaa-aabta-cai (dep_b) Creating canister: yahli-baaaa-aaaaa-aabtq-cai (dep_c) Installing canister: yahli-baaaa-aaaaa-aabtq-cai (dep_c) ``` -------------------------------- ### Install a specific canister Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Deploy a single canister by specifying its name. Ensure the name matches a canister configured in your `dfx.json` file. ```bash dfx canister install hello_world_backend ``` -------------------------------- ### List installed dfx versions Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-cache.mdx Lists all `dfx` versions currently installed in the cache. An asterisk (*) indicates the currently active version. ```bash dfx cache list ``` -------------------------------- ### Start dfx using PocketIC Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx The `--pocketic` flag explicitly instructs `dfx` to use PocketIC for the local replica. This is the default behavior if no other replica-related flags are specified. ```bash dfx start --pocketic ``` -------------------------------- ### Example account ID output Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-ledger.mdx This is an example of the output format for an account identifier generated by the `dfx ledger account-id` command. ```text 03e3d86f29a069c6f2c5c48e01bc084e4ea18ad02b0eec8fccadf4487183c223 ``` -------------------------------- ### dfx quickstart output Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-quickstart.mdx This output displays your DFX user principal, ledger account address, ICP balance, conversion rate, and mainnet wallet information. ```shell Your DFX user principal: hoqq7-3eo6j-dee4s-aiabk-6rqxw-kwgyo-rhru7-bdgmk-k5ipv-chkhx-cqe Your ledger account address: 594369ede58d796ee76912d66201409930c9528d804f49a8e3f432bff957eae9 Your ICP balance: 3.99910000 ICP Conversion rate: 1 ICP <> 3.3357 XDR Mainnet wallet canister: mwylj-4aaaa-aaaak-aflyq-cai Mainnet wallet balance: 66.28 TC ``` -------------------------------- ### Example init.json Content Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/pull-dependencies.md This JSON file stores the initialization arguments for each dependency, including both the string representation (`arg_str`) and the raw hexadecimal encoding (`arg_raw`). It is generated by `dfx deps init`. ```json { "canisters": { "yofga-2qaaa-aaaaa-aabsq-cai": { "arg_str": "11", "arg_raw": "4449444c00017d0b" }, "yhgn4-myaaa-aaaaa-aabta-cai": { "arg_str": null, "arg_raw": null }, "yahli-baaaa-aaaaa-aabtq-cai": { "arg_str": "(opt 22)", "arg_raw": "4449444c016e7d01000116" } } } ``` -------------------------------- ### View a Sample Process ID Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-stop.mdx This command displays a process identifier similar to the following example. ```bash 1896 ``` -------------------------------- ### Create Project Without Frontend Code Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Use the `--no-frontend` flag to skip installing any frontend template code. This is the default behavior if NodeJS is not installed. ```bash dfx new --no-frontend _project_name_ ``` -------------------------------- ### Display dfx Version Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-parent.mdx Run this command to check the currently installed version of the dfx CLI. ```bash dfx --version ``` -------------------------------- ### Initialization and Upgrade Methods Source: https://github.com/dfinity/sdk/blob/master/docs/design/asset-canister-interface.md The `init` and `post_upgrade` methods are automatically invoked by the system upon canister code installation. They accept a variant argument to distinguish between initialization and upgrade scenarios, and both can optionally configure permissions. ```APIDOC ## Method: `init` and `post_upgrade` ### Description These methods are called automatically by the system after new code is installed in the canister. They accept the same argument type, using a variant to differentiate between initialization and upgrade. The `set_permissions` field can be used to update principal lists for various permission types. ### Arguments `asset_canister_args`: variant { Init: record { set_permissions: opt record { prepare: vec principal; commit: vec principal; manage_permissions: vec principal; }; }; Upgrade: record { set_permissions: opt record { prepare: vec principal; commit: vec principal; manage_permissions: vec principal; }; }; } ``` -------------------------------- ### Print dfx.json Schema Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-schema.mdx This command displays the schema for the main `dfx.json` configuration file. It's useful for validating your project's setup. ```bash dfx schema ``` -------------------------------- ### Generate Declarations for 'hello_world' Canister Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-generate.mdx This example generates type declarations for the 'hello_world' canister, specifying that all four supported languages (Motoko, Candid, JavaScript, TypeScript) should be generated and placed in the `src/declarations/` directory. ```bash dfx generate hello_world ``` -------------------------------- ### Start dfx with a Clean State Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx Employ the `--clean` flag to initiate the local development environment and web server processes from a clean state. This removes checkpoints from the project cache, useful for troubleshooting or debugging. ```bash dfx start --clean ``` -------------------------------- ### Install canisters on a custom local network Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Deploy canisters to a specific local network by providing its URL. This overrides the network settings in your `dfx.json` file. ```bash dfx canister install --all --network http://192.168.3.1:5678 ``` -------------------------------- ### View dfx wallet subcommand help Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-wallet.mdx To view usage information for a specific `dfx wallet` subcommand, specify the subcommand and the `--help` flag. For example, to see usage information for `dfx wallet send`, you can run the following command. ```bash dfx wallet send --help ``` -------------------------------- ### Extract Rust Version from Metadata Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/tech-stack.md Example using `jq` to parse the 'dfx' metadata and extract the Rust version. This is useful for validating the configured tech stack. ```sh > dfx canister metadata dfx | jq -r ".tech_stack.language.rust.version" ``` ```text 1.75.0 ``` -------------------------------- ### Deploy all canisters Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deploy.mdx Deploys all canisters defined in the project's `dfx.json` configuration file. This command simplifies the developer workflow by enabling you to run one command instead of running `dfx canister create --all`, `dfx build`, and `dfx canister install --all` as separate steps. ```bash dfx deploy --all ``` -------------------------------- ### Install Canister Code Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Installs compiled code into a canister on the local development environment or the mainnet. You can install for a specific canister name or all canisters. ```bash dfx canister install [option] [--all | canister_name] ``` -------------------------------- ### Preview Project Creation Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Run this command with the `--dry-run` flag to see which directories and files would be created without modifying the file system. ```bash dfx new my_social_network --dry-run ``` -------------------------------- ### dfx canister start Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Starts a stopped canister. Use this command to resume operations of a canister that has been halted. ```APIDOC ## dfx canister start ### Description Starts a stopped canister. ### Method `dfx canister start` ### Endpoint N/A (CLI command) ### Parameters #### Command Arguments - `canister_id`: The ID or name of the canister to start. #### Options - `--network`: Specifies the network to use (e.g., `ic` for mainnet, `local`). ### Request Example ```bash dfx canister start my_canister ``` ### Response #### Success Response Indicates successful start of the canister. ``` -------------------------------- ### Create a New Project Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Use this command to create a new project and initialize its directory structure and Git repository. ```bash dfx new my_social_network ``` -------------------------------- ### Start a specific canister Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Starts a single specified canister. This command is typically used after a canister has been stopped and before it is upgraded. ```bash dfx canister start hello_world ``` -------------------------------- ### Create Project with Frontend Tests Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Add a `vitest` skeleton for frontend tests by including `frontend-tests` in the `--extras` flag. ```bash dfx new --extras frontend-tests _project_name_ ``` -------------------------------- ### Create a New Project Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Use this command to create a new project. Replace `_project_name_` with your desired project name. Optional flags can be appended. ```bash dfx new _project_name_ [flag] ``` -------------------------------- ### Create Project with Bitcoin and Internet Identity Extras Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Include boilerplate for `bitcoin` and `internet-identity` integration by specifying them in the `--extras` flag. ```bash dfx new --extras bitcoin,internet-identity _project_name_ ``` -------------------------------- ### Deploy a canister with initial cycles Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deploy.mdx Add an initial balance of 8000000000000 cycles to the 'hello-assets' canister during deployment. If no canister is specified, cycles are added to all canisters by default. ```bash dfx deploy --with-cycles 8000000000000 hello-assets ``` -------------------------------- ### Create SNS configuration file Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-sns.mdx Use the `dfx sns create` command to generate an SNS configuration file. This file is crucial for defining the legal and financial aspects of your dapp's decentralization. Remember to fill in blank parameters like the token name. ```bash dfx sns create ``` -------------------------------- ### Display dfx Help Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-help.mdx Use this command to view general usage information for the `dfx` parent command. This is useful when you need a quick overview of the tool's capabilities. ```bash dfx help ``` -------------------------------- ### dfx cache list Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-cache.mdx Lists the versions of `dfx` currently installed and used in projects. ```APIDOC ## dfx cache list Use the `dfx cache list` command to list `dfx` versions you have currently installed and used in projects. If you have multiple versions of `dfx` installed, the cache list displays an asterisk (") to indicate the currently active version. ### Basic usage ```bash dfx cache list [flag] ``` ### Example ```bash dfx cache list ``` This command displays the list of `dfx` versions found similar to the following: ```bash 0.6.4 * 0.6.3 0.6.0 ``` ``` -------------------------------- ### Deploy a specific canister to a custom network Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deploy.mdx Use this command to deploy a canister named 'hello_backend' to the 'ic-pubs' network. Ensure the network is configured in your `dfx.json`. ```bash dfx deploy hello_backend --network ic-pubs ``` -------------------------------- ### Basic dfx canister call syntax Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Illustrates the fundamental structure for calling a specified method on a deployed canister, including optional arguments. ```bash dfx canister call [options] [argument] ``` -------------------------------- ### dfx canister start Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Restarts a stopped canister on the mainnet or local development environment. Useful before upgrading canisters. ```APIDOC ## dfx canister start Restarts a stopped canister on the mainnet or the local development environment. ### Basic usage ```bash dfx canister start [--all | canister_name] ``` ### Arguments - `--all`: Starts all of the canisters configured in the `dfx.json` file. - `canister_name`: Specifies the name of the canister you want to start. ### Examples To start the `hello_world` canister: ```bash dfx canister start hello_world ``` To start all canisters deployed on the mainnet: ```bash dfx canister start --all --network=ic ``` ``` -------------------------------- ### Get canister logs Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Display logs from a specified canister. This command requires the canister name or ID as an argument. ```bash dfx canister logs [options] ``` -------------------------------- ### Preview Project Creation with Dry Run Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Use the `--dry-run` flag to see which directories and files would be created for a new project without actually creating them on your file system. ```bash dfx new --dry-run _project_name_ ``` -------------------------------- ### Create Project with Specific Backend Type Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-new.mdx Specify the backend canister template using the `--type` flag. Available options are `motoko`, `rust`, `azle`, and `kybra`. Defaults to `motoko`. ```bash dfx new --type rust _project_name_ ``` -------------------------------- ### Get Canister ID Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Use this command to retrieve the unique identifier for a specified canister. Replace `hello_world` with your canister's name. ```bash dfx canister id hello_world ``` -------------------------------- ### Get canister identifier Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Outputs the canister identifier for a given canister name. This command must be run from within the project directory. ```bash dfx canister id ``` -------------------------------- ### Get Principal for Specific Identity Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-identity.mdx Sets the user context to a specific identity and then retrieves its principal. This is useful for verifying identity-specific principals. ```bash dfx identity use ic_admin dfx identity get-principal ``` -------------------------------- ### Get Principal for Current Identity Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-identity.mdx Displays the principal associated with the current user identity context. Useful for testing authorization scenarios. ```bash dfx identity get-principal [flag] ``` -------------------------------- ### Deploy dependencies Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deps.mdx Use the `dfx deps deploy` command to deploy all dependencies. If some dependencies haven't been pulled or had their init arguments set, the command will fail with an error message to help you fix it. ```bash dfx deps deploy ``` -------------------------------- ### Upload Assets Using icx-asset CLI Source: https://github.com/dfinity/sdk/blob/master/src/canisters/frontend/ic-certified-assets/README.md Use the `icx-asset` command-line tool to synchronize local assets to your canister. Ensure you specify the correct PEM file and replica URL. ```bash cd assets icx-asset --pem ~/.config/dfx/identity/default/identity.pem --replica https://icp0.io sync . ``` -------------------------------- ### View local development environment PID Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-start.mdx Displays the current process identifier (pid) for the local development environment process started by dfx. ```bash more .dfx/pid ``` -------------------------------- ### Get wallet name Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-wallet.mdx Displays the name of the selected identity's cycles wallet, if it has been set using the `dfx wallet set-name` command. ```bash dfx wallet name [flag] ``` ```bash my_wallet ``` -------------------------------- ### Get Wallet Canister ID on Specific Network Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-identity.mdx Retrieves the wallet canister ID for your identity on a specified network, such as a local development environment. ```bash dfx identity get-wallet --network=https://192.168.74.4 ``` -------------------------------- ### dfx deps init Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-deps.mdx Sets initialization arguments for pulled dependencies. You can specify arguments for individual canisters by their ID or name. ```APIDOC ## dfx deps init Use the `dfx deps init` command to set init arguments for pulled dependencies. ### Basic usage ```bash dfx deps init [options] [canister] ``` ### Examples If any of the dependencies require init arguments, the above command will alarm you with their canister ID and names if exist. Then you can specify canister ID or name to set init argument for individual dependency. ```bash dfx deps init --argument [--argument-type ] ``` The command below set number `1` for canister `dep_a` as the argument type is the default `idl` (Candid). ```bash dfx deps init dep_a --argument 1 ``` The command below set the hex-encoded raw bytes for canister `dep_b`. ```bash dfx deps init dep_b --argument "4449444c00017103616263" --argument-type raw ``` The command below set the init argument for canister `dep_c` with the content of file `init_c.txt`. ```bash dfx deps init dep_c --argument-file init_c.txt ``` ``` -------------------------------- ### Create Batch Method (`create_batch`) Source: https://github.com/dfinity/sdk/blob/master/docs/design/asset-canister-interface.md Initiates a new batch for uploading assets and returns its unique ID. This method requires the 'Prepare' permission and has preconditions related to existing batches and creation limits. ```candid create_batch: (record {}) -> (BatchId); ``` -------------------------------- ### Display Help for dfx Subcommand Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-parent.mdx To view usage information for a specific subcommand, append the --help flag to the subcommand. ```bash dfx build --help ``` -------------------------------- ### Deploy SNS canisters locally Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-sns.mdx After creating and validating your SNS configuration, use `dfx sns deploy` to create the SNS canisters on your local testnet. This command initiates the deployment process based on your configuration file. ```bash dfx sns deploy ``` -------------------------------- ### Get cycles wallet principal on mainnet Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Retrieves the principal of your cycles wallet on the mainnet (`ic` network). This is often a prerequisite for specifying the wallet by principal. ```bash dfx identity get-wallet --network ic ``` -------------------------------- ### Basic dfx schema Usage Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-schema.mdx Prints the schema for the default `dfx.json` file. Use this to understand the structure and valid fields for your project's configuration. ```bash dfx schema [option] [flag] ``` -------------------------------- ### Check ICP Balance for a Principal Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-ledger.mdx Use this command to get the ICP balance of a specific principal on the IC network. Refer to the ICRC-1 standard for more details. ```bash dfx ledger balance --of-principal tdrdy-ztedg-ftfrj-mwmqh-wjl3j-pty4c-j63lp-xfvtt-7jxvp-4ialz-3ae --network ic ``` -------------------------------- ### dfx canister info Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Get the hash of a canister’s Wasm module and its current controller. This provides insights into the canister's deployment and management. ```APIDOC ## dfx canister info ### Description Get the hash of a canister’s Wasm module and its current controller. ### Method `dfx canister info` ### Endpoint N/A (CLI command) ### Parameters #### Command Arguments - `canister_id`: The ID or name of the canister. #### Options - `--network`: Specifies the network to use (e.g., `ic` for mainnet, `local`). ### Request Example ```bash dfx canister info my_canister ``` ### Response #### Success Response - `wasm_hash` (string): The hash of the canister's Wasm module. - `controller` (string): The principal ID of the canister's controller. ``` -------------------------------- ### Define Pullable Canister Metadata Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/canister-metadata.md Configure `pullable` metadata to make a canister pullable, specifying its WASM URL, hash, dependencies, and initialization guide. ```json { "pullable": { "wasm_url": "http://example.com/a.wasm", "wasm_hash": "d180f1e232bafcee7d4879d8a2260ee7bcf9a20c241468d0e9cf4aa15ef8f312", "dependencies": [ "yofga-2qaaa-aaaaa-aabsq-cai" ], "init_guide": "A natural number, e.g. 10." } } ``` -------------------------------- ### Create canisters with initial cycles Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-canister.mdx Specify an initial balance of cycles when creating one or all canisters in a project. The `--all` flag creates identifiers for all canisters defined in `dfx.json`. ```bash dfx canister create --with-cycles 8000000000000 --all ``` -------------------------------- ### Deploy Specific Pull Dependency by Name Source: https://github.com/dfinity/sdk/blob/master/docs/concepts/pull-dependencies.md Deploy a particular dependency by specifying its name with `dfx deps deploy`. This installs the specified canister with its init arguments. ```bash > dfx deps deploy dep_b Installing canister: yhgn4-myaaa-aaaaa-aabta-cai (dep_b) ``` -------------------------------- ### Build DFX and Add to PATH for E2E Tests Source: https://github.com/dfinity/sdk/blob/master/CONTRIBUTING.md Build the DFX project and export its target directory to the PATH environment variable to make the local dfx executable available for end-to-end tests. ```bash sdk $ cargo build sdk $ export PATH=$(pwd)/target/debug:$PATH ``` -------------------------------- ### Basic dfx ledger command syntax Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-ledger.mdx This is the general syntax for running any dfx ledger subcommand. Specific commands may require additional arguments, options, or flags. ```bash dfx ledger [subcommand] [options] ``` -------------------------------- ### Get Chunk Method Source: https://github.com/dfinity/sdk/blob/master/docs/design/asset-canister-interface.md Retrieves a specific chunk of an asset's content for a given encoding and index. Includes security checks using SHA256 hashes. ```APIDOC ## Method: `get_chunk` ### Description Retrieves a specific chunk of an asset's content for a given key and content encoding. It requires the chunk `index` and optionally a `sha256` hash for verification. The canister verifies the provided `sha256` against the content encoding to prevent tampering. ### Method `get_chunk` ### Query Parameters - `key` (Key) - The unique identifier for the asset. - `content_encoding` (text) - The content encoding of the chunk to retrieve. - `index` (nat) - The index of the chunk to retrieve. - `sha256` (opt blob) - The SHA256 hash of the content encoding for verification. ### Response #### Success Response (200) - `content` (blob) - The requested chunk of the asset's content. ``` -------------------------------- ### Show dfx identity subcommand help Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-identity.mdx To view usage information for a specific `dfx identity` subcommand, specify the subcommand and the `--help` flag. ```bash dfx identity new --help ``` -------------------------------- ### Show dfx sns subcommand help Source: https://github.com/dfinity/sdk/blob/master/docs/cli-reference/dfx-sns.mdx To view usage information for a specific subcommand, specify the subcommand and the `--help` flag. ```bash dfx sns validate --help ```