Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/concepts/trust-in-canisters.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The canisters, if not voluntarily made immutable, have complete control over the

The simplest option is to make the canister immutable by removing its controller. A user can verify the list of controllers for a canister <canister> using dfx. For example:

dfx canister --network ic info ryjl3-tyaaa-aaaaa-aaaba-cai
dfx canister info ryjl3-tyaaa-aaaaa-aaaba-cai --network ic

will return the list of controllers for the canister with principal `ryjl3-tyaaa-aaaaa-aaaba-cai` (in this example, the ledger canister).

Expand Down
22 changes: 11 additions & 11 deletions docs/developer-docs/build/backend/access-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ To review your current identity and principle:

3. Check the role associated with the `default` user identity by running the following command:

dfx canister --wallet=$(dfx identity get-wallet) call access_hello my_role
dfx canister call access_hello my_role --wallet="$(dfx identity get-wallet)"

The command displays output similar to the following:

Expand All @@ -160,7 +160,7 @@ To create a new user identity:

3. Call the `my_role` function to see that your new user identity has not been assigned to any role.

dfx --identity ic_admin canister call access_hello my_role
dfx canister call access_hello my_role --identity ic_admin

The command displays output similar to the following:

Expand Down Expand Up @@ -197,15 +197,15 @@ To assign the admin role to the IC\_admin identity:

2. Assign the `ic_admin` principal the `admin` role by running a command similar to the following using Candid syntax:

dfx canister --wallet=$(dfx identity get-wallet) call access_hello assign_role '((principal "c5wa6-3irl7-tuxuo-4vtyw-xsnhw-rv2a6-vcmdz-bzkca-vejmd-327zo-wae"),opt variant{admin})'
dfx canister call --wallet="$(dfx identity get-wallet)" access_hello assign_role '((principal "c5wa6-3irl7-tuxuo-4vtyw-xsnhw-rv2a6-vcmdz-bzkca-vejmd-327zo-wae"),opt variant{admin})'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dfx canister call --wallet="$(dfx identity get-wallet)" access_hello assign_role '((principal "c5wa6-3irl7-tuxuo-4vtyw-xsnhw-rv2a6-vcmdz-bzkca-vejmd-327zo-wae"),opt variant{admin})'
dfx canister call access_hello assign_role '((principal "c5wa6-3irl7-tuxuo-4vtyw-xsnhw-rv2a6-vcmdz-bzkca-vejmd-327zo-wae"),opt variant{admin})' --wallet="$(dfx identity get-wallet)"


Be sure to replace the `principal` hash with the one returned by the `dfx identity get-principal` command for the `ic_admin` identity.

\+ Optionally, you can rerun the command to call the `my_role` function to verify the role assignment.

\+

dfx --identity ic_admin canister call access_hello my_role
dfx canister call access_hello my_role --identity ic_admin

\+ The command displays output similar to the following:

Expand All @@ -215,7 +215,7 @@ Be sure to replace the `principal` hash with the one returned by the `dfx identi

1. Call the `greet` function using the `ic_admin` user identity that you just assigned the `admin` role by running the following command:

dfx --identity ic_admin canister call access_hello greet "Internet Computer Admin"
dfx canister call access_hello greet "Internet Computer Admin" --identity ic_admin

The command displays output similar to the following:

Expand Down Expand Up @@ -258,11 +258,11 @@ To add a new authorized user identity:

5. Use the `ic_admin` identity to assign the `authorized` role to `alice_auth` by running the following command:

dfx --identity ic_admin canister call access_hello assign_role "(principal \"$ALICE_ID\", opt variant{authorized})"
dfx canister call access_hello assign_role "(principal \"$ALICE_ID\", opt variant{authorized})" --identity ic_admin

6. Call the `my_role` function to verify the role assignment.

dfx --identity alice_auth canister call access_hello my_role
dfx canister call access_hello my_role --identity alice_auth

The command displays output similar to the following:

Expand Down Expand Up @@ -301,23 +301,23 @@ To add an unauthorized user identity:

4. Store the principal for the `bob_standard` user in an environment variable by running the following command:

BOB_ID=$(dfx --identity bob_standard identity get-principal)
BOB_ID=$(dfx identity get-principal --identity bob_standard)

5. Attempt to use the `bob_standard` identity to assign a role.

dfx --identity bob_standard canister call access_hello assign_role "(principal \"$BOB_ID\", opt variant{authorized})"
dfx canister call --identity bob_standard access_hello assign_role "(principal \"$BOB_ID\", opt variant{authorized})"

This command returns an `unauthorized` error.

6. Attempt to use the `default` user identity to assign `bob_standard` the `owner` role by running the following command:

dfx --identity default canister --wallet=$(dfx --identity default identity get-wallet) call access_hello assign_role "(principal \"$BOB_ID\", opt variant{owner})"
dfx canister call --identity default --wallet="$(dfx identity get-wallet --identity default)" access_hello assign_role "(principal \"$BOB_ID\", opt variant{owner})"

This command fails because users cannot be assigned the `owner` role.

7. Call the `greet` function using the `bob_standard` user identity by running the following command:

dfx --identity bob_standard canister call access_hello greet "Bob"
dfx canister call --identity bob_standard access_hello greet "Bob"

The command displays output similar to the following:

Expand Down
4 changes: 2 additions & 2 deletions docs/developer-docs/build/backend/reproducible-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Internet Computer does not allow you to access the Wasm code of an arbitrary can

To obtain this hash, you must first note the principal of the Internet Computer canister whose code you want to check. For example, assume we’re interested in the code of the Internet Identity canister, whose principal is `rdmx6-jaaaa-aaaaa-aaadq-cai`. Then, the easiest way to access this service is using the [`dfx`](https://internetcomputer.org/developers/) tool from the terminal. Open your terminal, and run:

$ dfx canister --network ic info rdmx6-jaaaa-aaaaa-aaadq-cai
$ dfx canister info rdmx6-jaaaa-aaaaa-aaadq-cai --network ic
Controllers: r7inp-6aaaa-aaaaa-aaabq-cai
Module hash: 0x2d95e90de5d7de11f25ac256690aff44c6685a1570b1becdf6e50192e983e103

Expand Down Expand Up @@ -235,6 +235,6 @@ Summarizing our recommendations for canister authors:

Finally, if your build is reproducible, you can compare the hash of the resulting Wasm code to the hash of the code that is running in a canister, which you retrieve as follows:

$ dfx canister --network ic info <canister-id>
$ dfx canister info <canister-id> --network ic

Beware that this hash might change if the controllers upgrade the canister code.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ To add identities for testing:
2. Call the `update` function to add a profile for the new identity. Enter your passphrase when prompted.

``` bash
dfx --identity Miles canister call rust_profile_backend update '(record {name = "Miles"; description = "Great Dane"; keywords = vec {"Boston"; "mantle"; "three-legged"}})'
dfx canister call --identity Miles rust_profile_backend update '(record {name = "Miles"; description = "Great Dane"; keywords = vec {"Boston"; "mantle"; "three-legged"}})'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dfx canister call --identity Miles rust_profile_backend update '(record {name = "Miles"; description = "Great Dane"; keywords = vec {"Boston"; "mantle"; "three-legged"}})'
dfx canister call rust_profile_backend update '(record {name = "Miles"; description = "Great Dane"; keywords = vec {"Boston"; "mantle"; "three-legged"}})' --identity Miles

```

3. Call the `getSelf` function to view the profile associated with the `default` user identity.
Expand All @@ -285,7 +285,7 @@ To add identities for testing:
4. Call the `getSelf` function using the `Miles` user identity by running the following command:

``` bash
dfx --identity Miles canister call rust_profile_backend getSelf
dfx canister call --identity Miles rust_profile_backend getSelf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dfx canister call --identity Miles rust_profile_backend getSelf
dfx canister call rust_profile_backend getSelf --identity Miles

```

The command displays the profile currently associated with the Miles identity, in this example:
Expand Down
10 changes: 5 additions & 5 deletions docs/developer-docs/build/project-setup/cycles-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To check the cycles balance on the Internet Computer:

3. Display the cycle balance from the cycles wallet associated with the currently-selected identity by running the following command:

dfx wallet --network ic balance
dfx wallet balance --network ic

The command displays output similar to the following:

Expand All @@ -108,7 +108,7 @@ To check the cycles balance on the Internet Computer:

You can also check the cycles balance by calling the `wallet_balance` method in the cycles wallet canister directly. For example, if your principal is a controller for the `h5aet-waaaa-aaaab-qaamq-cai` cycles wallet, you can check the current cycle balance by running the following command:

dfx canister --network ic call h5aet-waaaa-aaaab-qaamq-cai wallet_balance
dfx canister call h5aet-waaaa-aaaab-qaamq-cai wallet_balance --network ic

The command returns the balance using Candid format as a record with an amount field (represented by the hash 3\_573\_748\_184) and a balance of 6,895,656,625,450 cycles like this:

Expand All @@ -128,7 +128,7 @@ Use the `wallet_create_wallet` method to create a new cycles wallet canister wit

For example, you can run a command similar to the following to create a new wallet and assign a principal as a controller:

dfx canister --network call f3yw6-7qaaa-aaaab-qaabq-cai wallet_create_wallet '(record { cycles = 5000000000000 : nat64; controller = principal "vpqee-nujda-46rtu-4noo7-qnxmb-zqs7g-5gvqf-4gy7t-vuprx-u2urx-gqe"})'
dfx canister call f3yw6-7qaaa-aaaab-qaabq-cai wallet_create_wallet '(record { cycles = 5000000000000 : nat64; controller = principal "vpqee-nujda-46rtu-4noo7-qnxmb-zqs7g-5gvqf-4gy7t-vuprx-u2urx-gqe"})' --network ic

The command returns the principal for the new wallet:

Expand All @@ -140,7 +140,7 @@ Use the `wallet_create_canister` method to register a new canister principal on

For example, you can run a command similar to the following to create a new wallet and assign a principal as a controller:

dfx canister --network call f3yw6-7qaaa-aaaab-qaabq-cai wallet_create_canister '(record { cycles = 5000000000000 : nat64; controller = principal "vpqee-nujda-46rtu-4noo7-qnxmb-zqs7g-5gvqf-4gy7t-vuprx-u2urx-gqe"})'
dfx canister call f3yw6-7qaaa-aaaab-qaabq-cai wallet_create_canister '(record { cycles = 5000000000000 : nat64; controller = principal "vpqee-nujda-46rtu-4noo7-qnxmb-zqs7g-5gvqf-4gy7t-vuprx-u2urx-gqe"})' --network ic

The command returns the principal for the new canister you created:

Expand Down Expand Up @@ -176,7 +176,7 @@ For example, you can use the `get_events` method to return `canister_create` and

If the cycles wallet (`gastn-uqaaa-aaaae-aaafq-cai`) is deployed on the Internet Computer main network, you could run a command that looks like this to return events:

dfx canister --network ic call gastn-uqaaa-aaaae-aaafq-cai get_events '(record {from = null; to = null})'
dfx canister call gastn-uqaaa-aaaae-aaafq-cai get_events '(record {from = null; to = null})' --network ic

The output from the command is in Candid format similar to the following:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ You can look up the canister identifier for any specific canister by running the

To look up the canister identifier for the same canister deployed on the environment specified by the `ic` alias, you would run the following command:

dfx canister --network=ic id lookup
dfx canister id lookup --network=ic

## Add a Wallet for Existing Canisters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This tutorial will guide you step-by-step to deploy your own token to the IC and
6. Check that the Ledger canister is healthy. Execute the following command:

``` sh
dfx canister --network ${NETWORK} call ledger symbol
dfx canister call ledger symbol --network ${NETWORK}
```

The output should look like the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ Both commands provide a flag to specify a ledger canister id (`--ledger-canister

Get the ICP balance of a specific account:
``` bash
dfx ledger --network ic balance <account-id>
dfx ledger balance <account-id> --network ic
```
The `<account-id>` is encoded as a hex string.
In many cases you want to check the main account balance of a specific principal. You can use the following command for this:

``` bash
dfx ledger --network ic balance $(dfx ledger account-id --of-principal <principal-id>)
dfx ledger balance "$(dfx ledger account-id --of-principal <principal-id>)" --network ic
```

#### Transfer

The transfer function can be used to transfer ICP from your account to another.

``` bash
dfx ledger --network ic transfer --amount <amount> --memo <memo> <receiver-account-id>
dfx ledger transfer --amount <amount> --memo <memo> <receiver-account-id> --network ic
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ launch.
2. Make sure that you have at least 5 ICP in your main account; if not get more with the "Get ICP" menu entry.
3. Go to the neurons tab and create a neuron. Give it 5 ICP and an 8 year dissolve delay.
4. Make a note of your neuron ID. The rest of this guide will refer to it as `DEVELOPER_NEURON_ID`. The commands below assume you run `export DEVELOPER_NEURON_ID=<neuron id>` in your shell.
5. Add one of the dfx identities as a hotkey to the neuron. This dfx identity will be referred to as `developer-identity`. To get the principal of this identity, run `dfx --identity developer-identity identity get-principal`.
5. Add one of the dfx identities as a hotkey to the neuron. This dfx identity will be referred to as `developer-identity`. To get the principal of this identity, run `dfx identity get-principal --identity developer-identity`.

#### 3. Ask the SNS wasm modules canister to install an SNS.
Make a call to the SNS wasm modules canister on the local NNS to request that an SNS is installed.
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/quickstart/cycles-faucet.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ After a successfully running the `redeem` command, the created canister's ID is

After runninng the `redeem` command, the created canister and it's balance can be checked using the status command. Use the canister ID returned by the `redeem` command:

dfx canister --network=ic status <canister id>
dfx canister status <canister id> --network=ic

Please note the canister ID is used in the next step, so write down the canister ID.

Expand Down
26 changes: 13 additions & 13 deletions docs/developer-docs/quickstart/hello10mins.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ For the purposes of this tutorial, you can acquire free cycles for your `Hello`
Now that you have used the cycles faucet, in terminal B you can check your cycles balance:

``` bash
dfx wallet --network ic balance
dfx wallet balance --network ic
```

You should see around 20 trillion cycles if you run this after using the cycles wallet. If so, skip to section [5. Deploying on-chain](#5deploy-on-chain-1-min).
Expand All @@ -351,7 +351,7 @@ e213184a548871a47fb526f3cba24e2ee2fbbc8129c4ab497ef2ce535130a0a4
Once you have transferred some ICP tokens into this account (5-10$ worth should be plenty to get going), you can see the balance using this command:

``` bash
dfx ledger --network ic balance
dfx ledger balance --network ic
```

This will output something like this:
Expand All @@ -363,13 +363,13 @@ This will output something like this:
With those ICP tokens ready, you can start creating your cycles wallet. To start, you have to create a canister which will become your wallet. The base command for this is as follows:

``` bash
dfx ledger --network ic create-canister <your-principal-identifier> --amount <icp-tokens>
dfx ledger create-canister <your-principal-identifier> --amount <icp-tokens> --network ic
```

The two values you have to substitute are your own principal and the amount of tokens you want to convert. To figure out your own principal, use the output of `dfx identity get-principal`. If my principal is `tsqwz-udeik-5migd-ehrev-pvoqv-szx2g-akh5s-fkyqc-zy6q7-snav6-uqe` and I want to convert 2.3 ICP into cycles, the command looks like this:

``` bash
dfx ledger --network ic create-canister tsqwz-udeik-5migd-ehrev-pvoqv-szx2g-akh5s-fkyqc-zy6q7-snav6-uqe --amount 2.3
dfx ledger create-canister tsqwz-udeik-5migd-ehrev-pvoqv-szx2g-akh5s-fkyqc-zy6q7-snav6-uqe --amount 2.3 --network ic
```

This command will take some time and output something similar to the following:
Expand All @@ -384,13 +384,13 @@ The id in this output is the address of the canister where your wallet will live
Now that the canister is created, you can install the wallet code using this command:

``` bash
dfx identity --network ic deploy-wallet <canister-identifer>
dfx identity deploy-wallet <canister-identifer> --network ic
```

Here, you have to substitute the canister identifier using the id you received in the output of the previous command. So, in the example this would look like this:

``` bash
dfx identity --network ic deploy-wallet gastn-uqaaa-aaaae-aaafq-cai
dfx identity deploy-wallet gastn-uqaaa-aaaae-aaafq-cai --network ic
```

And the output should look like this:
Expand All @@ -403,15 +403,15 @@ The wallet canister on the "ic" network for user "default" is "gastn-uqaaa-aaaae
Now your wallet should be configured and ready to go. To check if everything went right, run this to see the identifier of your configured wallet:

``` bash
dfx identity --network ic get-wallet
dfx identity get-wallet --network ic
```

This should print the canister id you used in the commands earlier.

You can also check the balance of your new cycles wallet:

``` bash
dfx wallet --network ic balance
dfx wallet balance --network ic
```

This should print something looking like this:
Expand All @@ -430,7 +430,7 @@ npm install
```

``` bash
dfx deploy --network ic --with-cycles 1000000000000
dfx deploy --with-cycles 1000000000000 --network ic
```

The `--network` option specifies the network alias or URL for deploying the dapp. This option is required to install on the Internet Computer blockchain mainnet. `--with-cycles` explicitly tells `dfx` how many cycles to use, otherwise it will use the default of 3 trillion.
Expand Down Expand Up @@ -496,12 +496,12 @@ After loading the service worker, your dapp will load:
Since the canister has a method called `greet` (which accepts a string as a parameter), we can send it a message via `dfx`.

``` bash
dfx canister --network ic call hello_backend greet '("everyone": text)'
dfx canister call hello_backend greet '("everyone": text)' --network ic
```

Note the way the message is constructed:

- `dfx canister --network ic call` is the setup for calling a canister on the IC.
- `dfx canister call --network ic` is the setup for calling a canister on the IC.

- `hello_backend greet` means we are sending a message to a canister named `hello` and evoking its `greet` method. `dfx` knows which `hello` canister (out of the many in the IC), one refers to because a mapping of `hello` to a canister id is stored locally in `.dfx/local/canister_ids.json`.

Expand All @@ -522,7 +522,7 @@ dfx identity whoami
#### 2. Confirm the identity you are using has enough cycles on-chain

``` bash
dfx wallet --network ic balance
dfx wallet balance --network ic
```

#### 3. Try proxying through your wallet
Expand All @@ -532,7 +532,7 @@ Sometimes (especially when you created the canisters with `dfx` versions before
If this works and you would like to add your own principal as a controller of the canister (so you don’t have to use the `--wallet` option anymore), you can run this:

``` bash
dfx canister --wallet "$(dfx identity get-wallet)" update-settings --all --add-controller "$(dfx identity get-principal)"
dfx canister update-settings --wallet "$(dfx identity get-wallet)" --all --add-controller "$(dfx identity get-principal)"
```

## Wrap-up
Expand Down
4 changes: 2 additions & 2 deletions docs/developer-docs/quickstart/hello20mins.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ Now that the canister is deployed on-chain, you can send it a message.
Since the canister has a method called `greet` (which accepts a string
as a parameter), we will send it a message.

$ dfx canister --network ic call hello_backend greet '("everyone": text)'
$ dfx canister call hello_backend greet '("everyone": text)' --network ic

Note the way the message is constructed: \*
`dfx canister --network ic call` is setup for calling a canister on the
`dfx canister call --network ic` is setup for calling a canister on the
IC \* `hello_backend greet` means we are sending a message to a canister named
`hello_backend` and evoking its `greet` method \* `'("everyone": text)'` is the
parameter we are sending to `greet` (which accepts `Text` as its only
Expand Down
Loading