[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GPSX9GX9Y25TVRXJMBV6AS":3,"skill-same:01M6GPSX9GX9Y25TVRXJMBV6AS":89},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6GPSX9GX9Y25TVRXJMBV6AS","cycles-management",null,"Manage cycles and canister lifecycle. Covers cycle balance checks, top-ups, freezing thresholds, canister creation, and ICP-to-cycles conversion via the CMC. Use when working with cycles, canister funding, freezing threshold, frozen canister, out of cycles, top-up, canister creation, or cycle balance. Do NOT use for wallet-to-dApp integration or ICRC signer flows — use wallet-integration instead.","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-cycles-management\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-cycles-management\u002FSKILL.md",[],[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"management","cycles management","icp","when","funding","for","dapp","top","balance","with","flows","via","thresholds","cli","creation","cycle","do","manage","Wallet","conversion","up","use","lifecycle","2026-11-10 10:12:30",false,"---\nname: cycles-management\ndescription: \"Manage cycles and canister lifecycle. Covers cycle balance checks, top-ups, freezing thresholds, canister creation, and ICP-to-cycles conversion via the CMC. Use when working with cycles, canister funding, freezing threshold, frozen canister, out of cycles, top-up, canister creation, or cycle balance. Do NOT use for wallet-to-dApp integration or ICRC signer flows — use wallet-integration instead.\"\nlicense: Apache-2.0\ncompatibility: \"icp-cli >= 0.2.2\"\nmetadata:\n  title: Cycles Management\n  category: Infrastructure\n---\n\n# Cycles & Canister Management\n\n## What This Is\nCycles are the computation fuel for canisters on Internet Computer. Every canister operation (execution, storage, messaging) burns cycles. When a canister runs out of cycles, it freezes and is eventually uninstalled -- its code and data are deleted, but its metadata (canister ID, controllers, settings) survives. 1 trillion cycles (1T) costs approximately 1 USD equivalent in ICP (the exact rate is set by the NNS and fluctuates with ICP price via the CMC).\n\n**Note:** icp-cli uses the **cycles ledger** (`um5iw-rqaaa-aaaaq-qaaba-cai`) by default. The cycles ledger is a single canister that tracks cycle balances for all principals, similar to a token ledger. Commands like `icp cycles balance`, `icp cycles mint`, and `icp canister top-up` go through the cycles ledger. There is no legacy wallet concept in icp-cli. The programmatic patterns below (accepting cycles, creating canisters via management canister) remain the same regardless of which funding mechanism is used.\n\n## Prerequisites\n\n- For Motoko: `mops` package manager, `core = \"2.0.0\"` in mops.toml\n- For Rust: `ic-cdk >= 0.19`\n\n## Canister IDs\n\n| Service | Canister ID | Purpose |\n|---------|------------|---------|\n| Cycles Minting Canister (CMC) | `rkp4c-7iaaa-aaaaa-aaaca-cai` | Converts ICP to cycles, creates canisters |\n| Cycles Ledger | `um5iw-rqaaa-aaaaq-qaaba-cai` | Tracks cycle balances for all principals |\n| Management Canister | `aaaaa-aa` | Canister lifecycle (create, install, stop, delete, status) |\n\nThe Management Canister (`aaaaa-aa`) is a virtual canister -- it does not exist on a specific subnet but is handled by every subnet's execution layer.\n\n## Mistakes That Break Your Build\n\n1. **Running out of cycles silently freezes the canister** -- There is no warning. A frozen canister stops executing messages but keeps paying rent for its memory and allocations, so the balance continues to drain. When it reaches zero the canister is uninstalled: code and data are gone permanently, and only the metadata (canister ID, controllers, settings) remains. Set a freezing threshold and monitor balances.\n\n2. **Not setting freezing_threshold** -- Default is 30 days. If your canister burns cycles fast (high traffic, large stable memory), 30 days may not be enough warning. Set it higher for production canisters. The freezing threshold defines how many seconds worth of idle cycles the canister must retain before it freezes.\n\n3. **Confusing local vs mainnet cycles** -- Local replicas give canisters virtually unlimited cycles. Code that works locally may fail on mainnet because the canister has insufficient cycles. Always test with realistic cycle amounts before mainnet deployment.\n\n4. **Sending cycles to the wrong canister** -- Cycles sent to a canister cannot be retrieved. There is no refund mechanism for cycles transferred to the wrong principal. Double-check the canister ID before topping up.\n\n5. **Forgetting to set the canister controller** -- If you lose the controller identity, you permanently lose the ability to upgrade, top up, or manage the canister. Always add a backup controller. Use `icp canister settings update --add-controller PRINCIPAL` to add one.\n\n6. **Using ExperimentalCycles in mo:core** -- In mo:core 2.0, the module is renamed to `Cycles`. `import ExperimentalCycles \"mo:base\u002FExperimentalCycles\"` will fail. Use `import Cycles \"mo:core\u002FCycles\"`.\n\n7. **Using `icp cycles transfer` to fund a canister** -- `icp cycles transfer \u003Camount> \u003Cprincipal>` moves cycles between cycles-ledger balances, the same as a token transfer between accounts. Passing a canister's principal as the recipient credits that principal's cycles-ledger balance, not the canister's actual execution\u002Fcompute cycle balance -- `icp canister status` will not show the cycles as received, and the canister keeps burning down its real balance toward freezing with no indication anything went wrong. Use `icp canister top-up \u003Ccanister> --amount \u003CN> -e ic` instead, which deposits cycles directly onto the canister via the management canister. See \"Top Up a Canister\" below for both commands side by side.\n\n8. **Using `-n ic` on a command that names a canister** -- `-n`\u002F`--network` and `-e`\u002F`--environment` are different selectors and conflict with each other; passing both is an error. A canister **name** can only be resolved through an environment, so `-n` fails on it:\n\n   ```bash\n   icp canister status backend -n ic\n   # Error: Specifying a network is not supported if you are targeting a canister\n   # by name, specify an environment instead\n   ```\n\n   So `-e ic` for anything naming a canister (`top-up`, `status`, `settings update`, `create`), and `-n ic` for commands that take a principal or no canister at all (`cycles mint`, `cycles balance`, `cycles transfer`). This is why the mainnet examples below mix the two flags. Load `icp-cli` for the full flag rules.\n\n## Implementation\n\n### Motoko\n\n#### Checking and Accepting Cycles\n\n```motoko\nimport Cycles \"mo:core\u002FCycles\";\nimport Principal \"mo:core\u002FPrincipal\";\nimport Runtime \"mo:core\u002FRuntime\";\n\npersistent actor {\n\n  \u002F\u002F Check this canister's cycle balance\n  public query func getBalance() : async Nat {\n    Cycles.balance()\n  };\n\n  \u002F\u002F Accept cycles sent with a call (for \"tip jar\" or payment patterns)\n  public func deposit() : async Nat {\n    let available = Cycles.available();\n    if (available == 0) {\n      Runtime.trap(\"No cycles sent with this call\")\n    };\n    let accepted = Cycles.accept\u003Csystem>(available);\n    accepted\n  };\n\n  \u002F\u002F Send cycles to another canister via inter-canister call\n  public func topUpCanister(target : Principal) : async () {\n    let targetActor = actor (Principal.toText(target)) : actor {\n      deposit_cycles : shared () -> async ();\n    };\n    \u002F\u002F Attach 1T cycles to the call\n    await (with cycles = 1_000_000_000_000) targetActor.deposit_cycles();\n  };\n}\n```\n\n#### Creating a Canister Programmatically\n\n```motoko\nimport Principal \"mo:core\u002FPrincipal\";\n\npersistent actor Self {\n\n  type CanisterId = { canister_id : Principal };\n\n  type CreateCanisterSettings = {\n    controllers : ?[Principal];\n    compute_allocation : ?Nat;\n    memory_allocation : ?Nat;\n    freezing_threshold : ?Nat;\n  };\n\n  \u002F\u002F Management canister interface\n  let ic = actor (\"aaaaa-aa\") : actor {\n    create_canister : shared { settings : ?CreateCanisterSettings } ->\n      async CanisterId;\n    canister_status : shared { canister_id : Principal } ->\n      async {\n        status : { #running; #stopping; #stopped };\n        memory_size : Nat;\n        cycles : Nat;\n        settings : CreateCanisterSettings;\n        module_hash : ?Blob;\n      };\n    deposit_cycles : shared { canister_id : Principal } -> async ();\n    stop_canister : shared { canister_id : Principal } -> async ();\n    delete_canister : shared { canister_id : Principal } -> async ();\n  };\n\n  \u002F\u002F Create a new canister with 1T cycles\n  public func createNewCanister() : async Principal {\n    let result = await (with cycles = 1_000_000_000_000) ic.create_canister({\n      settings = ?{\n        controllers = ?[Principal.fromActor(Self)];\n        compute_allocation = null;\n        memory_allocation = null;\n        freezing_threshold = ?2_592_000; \u002F\u002F 30 days in seconds\n      };\n    });\n    result.canister_id\n  };\n\n  \u002F\u002F Check a canister's status and cycle balance\n  public func checkStatus(canisterId : Principal) : async Nat {\n    let status = await ic.canister_status({ canister_id = canisterId });\n    status.cycles\n  };\n\n  \u002F\u002F Top up another canister\n  public func topUp(canisterId : Principal, amount : Nat) : async () {\n    await (with cycles = amount) ic.deposit_cycles({ canister_id = canisterId });\n  };\n}\n```\n\n### Rust\n\n#### Checking Balance and Accepting Cycles\n\n```rust\nuse ic_cdk::{query, update};\nuse candid::Nat;\n\n#[query]\nfn get_balance() -> Nat {\n    Nat::from(ic_cdk::api::canister_cycle_balance())\n}\n\n#[update]\nfn deposit() -> Nat {\n    let available = ic_cdk::api::msg_cycles_available();\n    if available == 0 {\n        ic_cdk::trap(\"No cycles sent with this call\");\n    }\n    let accepted = ic_cdk::api::msg_cycles_accept(available);\n    Nat::from(accepted)\n}\n```\n\n#### Creating and Managing Canisters\n\n```rust\nuse candid::{Nat, Principal};\nuse ic_cdk::update;\nuse ic_cdk::management_canister::{\n    create_canister_with_extra_cycles, canister_status, deposit_cycles, stop_canister, delete_canister,\n    CreateCanisterArgs, CanisterStatusArgs, DepositCyclesArgs, StopCanisterArgs, DeleteCanisterArgs,\n    CanisterSettings, CanisterStatusResult,\n};\n\n#[update]\nasync fn create_new_canister() -> Principal {\n    let caller = ic_cdk::api::canister_self(); \u002F\u002F capture canister's own principal\n    let user = ic_cdk::api::msg_caller(); \u002F\u002F capture caller before await\n\n    let settings = CanisterSettings {\n        controllers: Some(vec![caller, user]),\n        compute_allocation: None,\n        memory_allocation: None,\n        freezing_threshold: Some(Nat::from(2_592_000u64)), \u002F\u002F 30 days\n        reserved_cycles_limit: None,\n        log_visibility: None,\n        wasm_memory_limit: None,\n        wasm_memory_threshold: None,\n        environment_variables: None,\n    };\n\n    let arg = CreateCanisterArgs {\n        settings: Some(settings),\n    };\n\n    \u002F\u002F Send 1T cycles with the create call\n    let result = create_canister_with_extra_cycles(&arg, 1_000_000_000_000u128)\n        .await\n        .expect(\"Failed to create canister\");\n\n    result.canister_id\n}\n\n#[update]\nasync fn check_status(canister_id: Principal) -> CanisterStatusResult {\n    canister_status(&CanisterStatusArgs { canister_id })\n        .await\n        .expect(\"Failed to get canister status\")\n}\n\n#[update]\nasync fn top_up(canister_id: Principal, amount: u128) {\n    deposit_cycles(&DepositCyclesArgs { canister_id }, amount)\n        .await\n        .expect(\"Failed to deposit cycles\");\n}\n\n#[update]\nasync fn stop_and_delete(canister_id: Principal) {\n    stop_canister(&StopCanisterArgs { canister_id })\n        .await\n        .expect(\"Failed to stop canister\");\n\n    delete_canister(&DeleteCanisterArgs { canister_id })\n        .await\n        .expect(\"Failed to delete canister\");\n}\n```\n\n## Deploy & Test\n\n### Check Cycle Balance\n\n```bash\n# Check your canister's cycle balance\nicp canister status backend\n# Look for \"Balance:\" line in output\n\n# Check balance on mainnet\nicp canister status backend -e ic\n\n# Check any canister by ID\nicp canister status ryjl3-tyaaa-aaaaa-aaaba-cai -e ic\n```\n\n### Top Up a Canister\n\n```bash\n# Top up with cycles from the cycles ledger (local)\nicp canister top-up backend --amount 1000000000000\n# Adds 1T cycles to the backend canister\n\n# Top up on mainnet\nicp canister top-up backend --amount 1000000000000 -e ic\n\n# Convert ICP to cycles and top up in one step (mainnet)\nicp cycles mint --icp 1.0 -n ic   # no canister argument, so -n is fine (see Pitfall 8)\n\n# No ICP to convert? Buy cycles with a card for the identity instead (load the `buy-cycles` skill)\nicp cycles buy --amount 10 -n ic\nicp canister top-up backend --amount 1000000000000 -e ic\n```\n\n```bash\n# CORRECT -- funds the canister's execution balance:\nicp canister top-up backend --amount 600b -e ic\n\n# WRONG -- sends to the recipient's cycles-ledger balance, canister cannot use it:\nicp cycles transfer 600000000000 \u003Ccanister-principal> -n ic\n```\n\n`--amount` on `icp canister top-up` accepts `k`\u002F`m`\u002F`b`\u002F`t` suffixes (thousand\u002Fmillion\u002Fbillion\u002Ftrillion).\n\n### Create a Canister via icp\n\n```bash\n# Create an empty canister (local)\nicp canister create my_canister\n\n# Create on mainnet with specific cycles\nicp canister create my_canister -e ic --cycles 2000000000000\n\n# Add a backup controller\nicp canister settings update my_canister --add-controller BACKUP_PRINCIPAL_HERE\n```\n\nEach creation takes `--cycles` (default 2T) plus the cycles ledger's 100M fee out of the identity's balance. Before `icp deploy -e ic` creates several canisters at once, estimate `N × (2T + 100M)`, compare with `icp cycles balance -n ic`, and close any gap before deploying -- `icp cycles mint --cycles \u003Cgap> -n ic` with ICP, `icp cycles buy --cycles \u003Cgap> -n ic` with a card. The `icp-cli` skill's \"Funding an identity for mainnet\" section has the steps.\n\n### Set Freezing Threshold\n\n```bash\n# Set freezing threshold to 90 days (in seconds: 90 * 24 * 60 * 60 = 7776000)\nicp canister settings update backend --freezing-threshold 7776000\n\n# Mainnet\nicp canister settings update backend --freezing-threshold 7776000 -e ic\n```\n\n## Verify It Works\n\n```bash\n# Deploy and check status\nicp network start -d\nicp deploy backend\nicp canister status backend\n# Expected output includes:\n#   Status: Running\n#   Balance: 3_100_000_000_000 Cycles (local default, varies)\n#   Freezing threshold: 2_592_000\n\n# Check balance programmatically (if you added getBalance)\nicp canister call backend getBalance '()'\n# Expected: a large nat value, e.g. (3_100_000_000_000 : nat)\n\n# On mainnet: verify cycles balance is not zero\nicp canister status backend -e ic\n# If Balance shows 0, the canister will freeze. Top up immediately.\n```\n","# Cycles & Canister Management\n\n## What This Is\nCycles are the computation fuel for canisters on Internet Computer. Every canister operation (execution, storage, messaging) burns cycles. When a canister runs out of cycles, it freezes and is eventually uninstalled -- its code and data are deleted, but its metadata (canister ID, controllers, settings) survives. 1 trillion cycles (1T) costs approximately 1 USD equivalent in ICP (the exact rate is set by the NNS and fluctuates with ICP price via the CMC).\n\n**Note:** icp-cli uses the **cycles ledger** (`um5iw-rqaaa-aaaaq-qaaba-cai`) by default. The cycles ledger is a single canister that tracks cycle balances for all principals, similar to a token ledger. Commands like `icp cycles balance`, `icp cycles mint`, and `icp canister top-up` go through the cycles ledger. There is no legacy wallet concept in icp-cli. The programmatic patterns below (accepting cycles, creating canisters via management canister) remain the same regardless of which funding mechanism is used.\n\n## Prerequisites\n\n- For Motoko: `mops` package manager, `core = \"2.0.0\"` in mops.toml\n- For Rust: `ic-cdk >= 0.19`\n\n## Canister IDs\n\n| Service | Canister ID | Purpose |\n|---------|------------|---------|\n| Cycles Minting Canister (CMC) | `rkp4c-7iaaa-aaaaa-aaaca-cai` | Converts ICP to cycles, creates canisters |\n| Cycles Ledger | `um5iw-rqaaa-aaaaq-qaaba-cai` | Tracks cycle balances for all principals |\n| Management Canister | `aaaaa-aa` | Canister lifecycle (create, install, stop, delete, status) |\n\nThe Management Canister (`aaaaa-aa`) is a virtual canister -- it does not exist on a specific subnet but is handled by every subnet's execution layer.\n\n## Mistakes That Break Your Build\n\n1. **Running out of cycles silently freezes the canister** -- There is no warning. A frozen canister stops executing messages but keeps paying rent for its memory and allocations, so the balance continues to drain. When it reaches zero the canister is uninstalled: code and data are gone permanently, and only the metadata (canister ID, controllers, settings) remains. Set a freezing threshold and monitor balances.\n\n2. **Not setting freezing_threshold** -- Default is 30 days. If your canister burns cycles fast (high traffic, large stable memory), 30 days may not be enough warning. Set it higher for production canisters. The freezing threshold defines how many seconds worth of idle cycles the canister must retain before it freezes.\n\n3. **Confusing local vs mainnet cycles** -- Local replicas give canisters virtually unlimited cycles. Code that works locally may fail on mainnet because the canister has insufficient cycles. Always test with realistic cycle amounts before mainnet deployment.\n\n4. **Sending cycles to the wrong canister** -- Cycles sent to a canister cannot be retrieved. There is no refund mechanism for cycles transferred to the wrong principal. Double-check the canister ID before topping up.\n\n5. **Forgetting to set the canister controller** -- If you lose the controller identity, you permanently lose the ability to upgrade, top up, or manage the canister. Always add a backup controller. Use `icp canister settings update --add-controller PRINCIPAL` to add one.\n\n6. **Using ExperimentalCycles in mo:core** -- In mo:core 2.0, the module is renamed to `Cycles`. `import ExperimentalCycles \"mo:base\u002FExperimentalCycles\"` will fail. Use `import Cycles \"mo:core\u002FCycles\"`.\n\n7. **Using `icp cycles transfer` to fund a canister** -- `icp cycles transfer \u003Camount> \u003Cprincipal>` moves cycles between cycles-ledger balances, the same as a token transfer between accounts. Passing a canister's principal as the recipient credits that principal's cycles-ledger balance, not the canister's actual execution\u002Fcompute cycle balance -- `icp canister status` will not show the cycles as received, and the canister keeps burning down its real balance toward freezing with no indication anything went wrong. Use `icp canister top-up \u003Ccanister> --amount \u003CN> -e ic` instead, which deposits cycles directly onto the canister via the management canister. See \"Top Up a Canister\" below for both commands side by side.\n\n8. **Using `-n ic` on a command that names a canister** -- `-n`\u002F`--network` and `-e`\u002F`--environment` are different selectors and conflict with each other; passing both is an error. A canister **name** can only be resolved through an environment, so `-n` fails on it:\n\n   ```bash\n   icp canister status backend -n ic\n   # Error: Specifying a network is not supported if you are targeting a canister\n   # by name, specify an environment instead\n   ```\n\n   So `-e ic` for anything naming a canister (`top-up`, `status`, `settings update`, `create`), and `-n ic` for commands that take a principal or no canister at all (`cycles mint`, `cycles balance`, `cycles transfer`). This is why the mainnet examples below mix the two flags. Load `icp-cli` for the full flag rules.\n\n## Implementation\n\n### Motoko\n\n#### Checking and Accepting Cycles\n\n```motoko\nimport Cycles \"mo:core\u002FCycles\";\nimport Principal \"mo:core\u002FPrincipal\";\nimport Runtime \"mo:core\u002FRuntime\";\n\npersistent actor {\n\n  \u002F\u002F Check this canister's cycle balance\n  public query func getBalance() : async Nat {\n    Cycles.balance()\n  };\n\n  \u002F\u002F Accept cycles sent with a call (for \"tip jar\" or payment patterns)\n  public func deposit() : async Nat {\n    let available = Cycles.available();\n    if (available == 0) {\n      Runtime.trap(\"No cycles sent with this call\")\n    };\n    let accepted = Cycles.accept\u003Csystem>(available);\n    accepted\n  };\n\n  \u002F\u002F Send cycles to another canister via inter-canister call\n  public func topUpCanister(target : Principal) : async () {\n    let targetActor = actor (Principal.toText(target)) : actor {\n      deposit_cycles : shared () -> async ();\n    };\n    \u002F\u002F Attach 1T cycles to the call\n    await (with cycles = 1_000_000_000_000) targetActor.deposit_cycles();\n  };\n}\n```\n\n#### Creating a Canister Programmatically\n\n```motoko\nimport Principal \"mo:core\u002FPrincipal\";\n\npersistent actor Self {\n\n  type CanisterId = { canister_id : Principal };\n\n  type CreateCanisterSettings = {\n    controllers : ?[Principal];\n    compute_allocation : ?Nat;\n    memory_allocation : ?Nat;\n    freezing_threshold : ?Nat;\n  };\n\n  \u002F\u002F Management canister interface\n  let ic = actor (\"aaaaa-aa\") : actor {\n    create_canister : shared { settings : ?CreateCanisterSettings } ->\n      async CanisterId;\n    canister_status : shared { canister_id : Principal } ->\n      async {\n        status : { #running; #stopping; #stopped };\n        memory_size : Nat;\n        cycles : Nat;\n        settings : CreateCanisterSettings;\n        module_hash : ?Blob;\n      };\n    deposit_cycles : shared { canister_id : Principal } -> async ();\n    stop_canister : shared { canister_id : Principal } -> async ();\n    delete_canister : shared { canister_id : Principal } -> async ();\n  };\n\n  \u002F\u002F Create a new canister with 1T cycles\n  public func createNewCanister() : async Principal {\n    let result = await (with cycles = 1_000_000_000_000) ic.create_canister({\n      settings = ?{\n        controllers = ?[Principal.fromActor(Self)];\n        compute_allocation = null;\n        memory_allocation = null;\n        freezing_threshold = ?2_592_000; \u002F\u002F 30 days in seconds\n      };\n    });\n    result.canister_id\n  };\n\n  \u002F\u002F Check a canister's status and cycle balance\n  public func checkStatus(canisterId : Principal) : async Nat {\n    let status = await ic.canister_status({ canister_id = canisterId });\n    status.cycles\n  };\n\n  \u002F\u002F Top up another canister\n  public func topUp(canisterId : Principal, amount : Nat) : async () {\n    await (with cycles = amount) ic.deposit_cycles({ canister_id = canisterId });\n  };\n}\n```\n\n### Rust\n\n#### Checking Balance and Accepting Cycles\n\n```rust\nuse ic_cdk::{query, update};\nuse candid::Nat;\n\n#[query]\nfn get_balance() -> Nat {\n    Nat::from(ic_cdk::api::canister_cycle_balance())\n}\n\n#[update]\nfn deposit() -> Nat {\n    let available = ic_cdk::api::msg_cycles_available();\n    if available == 0 {\n        ic_cdk::trap(\"No cycles sent with this call\");\n    }\n    let accepted = ic_cdk::api::msg_cycles_accept(available);\n    Nat::from(accepted)\n}\n```\n\n#### Creating and Managing Canisters\n\n```rust\nuse candid::{Nat, Principal};\nuse ic_cdk::update;\nuse ic_cdk::management_canister::{\n    create_canister_with_extra_cycles, canister_status, deposit_cycles, stop_canister, delete_canister,\n    CreateCanisterArgs, CanisterStatusArgs, DepositCyclesArgs, StopCanisterArgs, DeleteCanisterArgs,\n    CanisterSettings, CanisterStatusResult,\n};\n\n#[update]\nasync fn create_new_canister() -> Principal {\n    let caller = ic_cdk::api::canister_self(); \u002F\u002F capture canister's own principal\n    let user = ic_cdk::api::msg_caller(); \u002F\u002F capture caller before await\n\n    let settings = CanisterSettings {\n        controllers: Some(vec![caller, user]),\n        compute_allocation: None,\n        memory_allocation: None,\n        freezing_threshold: Some(Nat::from(2_592_000u64)), \u002F\u002F 30 days\n        reserved_cycles_limit: None,\n        log_visibility: None,\n        wasm_memory_limit: None,\n        wasm_memory_threshold: None,\n        environment_variables: None,\n    };\n\n    let arg = CreateCanisterArgs {\n        settings: Some(settings),\n    };\n\n    \u002F\u002F Send 1T cycles with the create call\n    let result = create_canister_with_extra_cycles(&arg, 1_000_000_000_000u128)\n        .await\n        .expect(\"Failed to create canister\");\n\n    result.canister_id\n}\n\n#[update]\nasync fn check_status(canister_id: Principal) -> CanisterStatusResult {\n    canister_status(&CanisterStatusArgs { canister_id })\n        .await\n        .expect(\"Failed to get canister status\")\n}\n\n#[update]\nasync fn top_up(canister_id: Principal, amount: u128) {\n    deposit_cycles(&DepositCyclesArgs { canister_id }, amount)\n        .await\n        .expect(\"Failed to deposit cycles\");\n}\n\n#[update]\nasync fn stop_and_delete(canister_id: Principal) {\n    stop_canister(&StopCanisterArgs { canister_id })\n        .await\n        .expect(\"Failed to stop canister\");\n\n    delete_canister(&DeleteCanisterArgs { canister_id })\n        .await\n        .expect(\"Failed to delete canister\");\n}\n```\n\n## Deploy & Test\n\n### Check Cycle Balance\n\n```bash\n# Check your canister's cycle balance\nicp canister status backend\n# Look for \"Balance:\" line in output\n\n# Check balance on mainnet\nicp canister status backend -e ic\n\n# Check any canister by ID\nicp canister status ryjl3-tyaaa-aaaaa-aaaba-cai -e ic\n```\n\n### Top Up a Canister\n\n```bash\n# Top up with cycles from the cycles ledger (local)\nicp canister top-up backend --amount 1000000000000\n# Adds 1T cycles to the backend canister\n\n# Top up on mainnet\nicp canister top-up backend --amount 1000000000000 -e ic\n\n# Convert ICP to cycles and top up in one step (mainnet)\nicp cycles mint --icp 1.0 -n ic   # no canister argument, so -n is fine (see Pitfall 8)\n\n# No ICP to convert? Buy cycles with a card for the identity instead (load the `buy-cycles` skill)\nicp cycles buy --amount 10 -n ic\nicp canister top-up backend --amount 1000000000000 -e ic\n```\n\n```bash\n# CORRECT -- funds the canister's execution balance:\nicp canister top-up backend --amount 600b -e ic\n\n# WRONG -- sends to the recipient's cycles-ledger balance, canister cannot use it:\nicp cycles transfer 600000000000 \u003Ccanister-principal> -n ic\n```\n\n`--amount` on `icp canister top-up` accepts `k`\u002F`m`\u002F`b`\u002F`t` suffixes (thousand\u002Fmillion\u002Fbillion\u002Ftrillion).\n\n### Create a Canister via icp\n\n```bash\n# Create an empty canister (local)\nicp canister create my_canister\n\n# Create on mainnet with specific cycles\nicp canister create my_canister -e ic --cycles 2000000000000\n\n# Add a backup controller\nicp canister settings update my_canister --add-controller BACKUP_PRINCIPAL_HERE\n```\n\nEach creation takes `--cycles` (default 2T) plus the cycles ledger's 100M fee out of the identity's balance. Before `icp deploy -e ic` creates several canisters at once, estimate `N × (2T + 100M)`, compare with `icp cycles balance -n ic`, and close any gap before deploying -- `icp cycles mint --cycles \u003Cgap> -n ic` with ICP, `icp cycles buy --cycles \u003Cgap> -n ic` with a card. The `icp-cli` skill's \"Funding an identity for mainnet\" section has the steps.\n\n### Set Freezing Threshold\n\n```bash\n# Set freezing threshold to 90 days (in seconds: 90 * 24 * 60 * 60 = 7776000)\nicp canister settings update backend --freezing-threshold 7776000\n\n# Mainnet\nicp canister settings update backend --freezing-threshold 7776000 -e ic\n```\n\n## Verify It Works\n\n```bash\n# Deploy and check status\nicp network start -d\nicp deploy backend\nicp canister status backend\n# Expected output includes:\n#   Status: Running\n#   Balance: 3_100_000_000_000 Cycles (local default, varies)\n#   Freezing threshold: 2_592_000\n\n# Check balance programmatically (if you added getBalance)\nicp canister call backend getBalance '()'\n# Expected: a large nat value, e.g. (3_100_000_000_000 : nat)\n\n# On mainnet: verify cycles balance is not zero\nicp canister status backend -e ic\n# If Balance shows 0, the canister will freeze. Top up immediately.\n```\n",{"name":5,"license":15,"metadata":48,"description":7,"compatibility":51},{"title":49,"category":50},"Cycles Management","Infrastructure","icp-cli >= 0.2.2","main","3df1d0d67b30ff15236561f8c0f9f06d33f42dfd","skills\u002Fchains\u002Fdfinity-official-cycles-management",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill cycles-management",{"tool":67,"command":68},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill cycles-management",{"tool":70,"command":71},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill cycles-management","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-cycles-management\u002FSKILL.md",true,[75,79,85],{"path":76,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":16},"LICENSE","许可证",10770,{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"SOURCE.md","REFERENCE","参考文档",335,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-cycles-management\u002FSOURCE.md",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"TRUST.auto.yaml",2149,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-cycles-management\u002FTRUST.auto.yaml",[90,100,108,116,124,132],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":99},"01M7DTKCERMV0RNX3HZJP4CZ26","troves","Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say \"Troves\" explicitly.","MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":99},"01M7DTK6CJSMGC8KCQHGNYFZBD","trade","Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say \"swap\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":112,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":99},"01M7DTJZ6A0X4PAW3Y8W4J9K64","staking","Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say \"stake\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":120,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":99},"01M7DTJSDZJKCDMW7GHRF4BRH5","send","Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say \"pay 10 STRK to 0x...\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":128,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":99},"01M7DTJG1E480D51ZQ7WKDQ26K","portfolio","View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks \"what do I have\", \"show me everything\", \"how much am I worth\", \"my positions\", \"my investments\", \"rebalance my portfolio\", \"I want 50% ETH\", \"optimize my holdings\", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say \"portfolio\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FSKILL.md",[],[],{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":136,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":99},"01M7DTJ7M8TE9R2N36HFBZDGVD","multi-swap","Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions \"two swaps\", \"three swaps\", \"swap X and Y at the same time\", or wants to convert multiple tokens in a single call.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FSKILL.md",[],[]]