Skip to content

Commit

Permalink
Merge pull request #3769 from dfinity/jessiemongeon1-patch-3
Browse files Browse the repository at this point in the history
update: topping up canisters
  • Loading branch information
jessiemongeon1 authored Nov 19, 2024
2 parents 71c2b49 + 9873f90 commit 6375d58
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Balance: 9_811_813_913_485 Cycles
Module hash: 0xe7866e1949e3688a78d8d29bd63e1c13cd6bfb8fbe29444fa606a20e0b1e33f0
```

Canisters can check their own balance programmatically. For example:
Canisters can check their balance programmatically. For example:

<AdornedTabs groupId="language">
<TabItem value="motoko" label="Motoko" default>
Expand Down Expand Up @@ -100,7 +100,7 @@ let current_canister_balance = ic_cdk::api::canister_balance();

### Option 1: If you have ICP on your account

If you have ICP on the account associated with a `dfx` identity, you can tell the ledger canister to take some of that ICP, convert it to cycles, and give it to a canister of your choice using the command `dfx ledger top-up --icp <AMOUNT> <DESTINATION> --network ic`:
If you have ICP on the account associated with a `dfx` identity, you can convert ICP into cycles, then top up a canister with those cycles:

```bash
dfx ledger account-id
Expand All @@ -115,7 +115,7 @@ dfx ledger top-up --icp 1 jqylk-byaaa-aaaal-qbymq-cai --network ic

### Option 2: If you have cycles

If you have a cycles balance associated with your developer identity, you can top up a canister with the command `dfx cycles top-up <DESTINATION> <AMOUNT>`:
If you already have cycles, you can top up a canister with the command `dfx cycles top-up <DESTINATION> <AMOUNT>`:

```bash
dfx cycles balance --network ic
Expand Down Expand Up @@ -150,7 +150,7 @@ dfx wallet balance --network ic
dfx wallet send 1T dfds-sddds-aaaal-qbsms-cai --network ic
```

-   The `wallet balance --network ic ` checks the cycles balance of your cycles wallet on the mainnet.
-   The `wallet balance --network ic` checks the cycles balance of your cycles wallet on the mainnet.
-   The `wallet send 1T dfds-sddds-aaaal-qbsms-cai --network ic` takes one trillion cycles from your cycles wallet and sends them to cycles wallet `dfds-sddds-aaaal-qbsms-cai`.

## Topping up a canister with the NNS frontend dapp
Expand All @@ -159,25 +159,25 @@ You can also top up any canister via the [NNS frontend dapp](https://nns.ic0.app

- #### Step 1: Navigate to the **My Canisters** section of the dapp.
- #### Step 2: Click **Link Canister**.
- #### Step 3: Add a canister principal. It is not necessary for the user to actually control said canister.
- #### Step 3: Add a canister principal. The user doesn't need to control the canister.
- #### Step 4: Once the canister is added, click on that canister.
- #### Step 5: Click `Add cycles` to add cycles using the ICP in your NNS frontend dapp.

## Managing cycle depletion with freezing threshold

ICP features a mechanism to prevent canisters from running out of cycles. Canisters have a configurable `freezing_threshold`, dynamically evaluated in cycles.

In the output of the `dfx canister status` command, you may have noticed the `freezing threshold` value. The freezing threshold is a value defined in seconds, which is used to calculate how many cycles a canister must retain in its cycles balance. This calculation is based off of the canister's memory consumption. The default freezing threshold value is `2_592_000s`, which corresponds to 30 days.
In the output of the `dfx canister status` command, you may have noticed the `freezing threshold` value. The freezing threshold is a value defined in seconds, which is used to calculate how many cycles a canister must retain in its cycles balance. This calculation is based on the canister's memory consumption. The default freezing threshold value is `2_592_000s`, which corresponds to 30 days.

The freezing threshold is important because if a canister runs out of cycles, it will be uninstalled. The freezing threshold protects it from deletion, since if the cycles balance dips below the threshold, the canister will stop processing any new requests; however, it will continue to reply to existing requests.
The freezing threshold is important because if a canister runs out of cycles, it will be uninstalled. The freezing threshold protects it from deletion since if the cycles balance dips below the threshold, the canister will stop processing any new requests; however, it will continue to reply to existing requests.

For example, to set a freezing threshold for your `poll_backend` canister, use the command:

``````bash
```
dfx canister update-settings poll_backend --freezing-threshold 3472000
```

Then, you can confirm that this threshold has been set by running the `dfx canister status poll_backend --network ic ` command again:
Then, confirm that this threshold has been set by running the `dfx canister status poll_backend --network ic ` command again:

```bash
Canister status call result for poll_backend.
Expand Down

0 comments on commit 6375d58

Please sign in to comment.