How to create a canister using the cycle ledger?

Hello,

There is an interface in the cycle ledger (GitHub - dfinity/cycles-ledger: The cycles ledger is a global ledger canister that enables principal IDs to hold cycles.) to create a canister. Can it be used from dfx?

Despite testing various commands (dfx deploy, dfx canister create) with the --no-wallet flag, I haven’t find a way to deploy canisters without a cycle wallet.

I don’t know if this has made it’s way into dfx yet, but the cycle ledger does have the following endpoints.

    // for creating a canister with cycles on your cycle ledger account
    create_canister : shared CreateCanisterArgs -> async {
      #Ok : CreateCanisterSuccess;
      #Err : CreateCanisterError;
    };
    // for creating a canister with approved cycles from another account
    create_canister_from : shared CreateCanisterFromArgs -> async {
        #Ok : CreateCanisterSuccess;
        #Err : CreateCanisterFromError;
      };

You can view the full type definition from the Candid here → https://dashboard.internetcomputer.org/canister/um5iw-rqaaa-aaaaq-qaaba-cai

In case you’re wondering about how to migrate from XTC/Cycles Wallet to the new Cycles Ledger, the CycleOps team put together some tutorials that should help you get onboarded onto the new Cycles Ledger

1 Like

Byron already explained how to use the cycles ledger without dfx. Regarding dfx:

Cycles ledger support is not fully enabled yet. You can enable it manually like this. It will be enabled completely starting with the beta that we’ll release this week.

BUT… If your identity has a cycles wallet configured, then dfx will stay in ‘wallet land’ and not use the cycles ledger. The --no-wallet flag is misleading in this case. I need to think about how we can rephrase that one.

So the way to go for you is to upgrade to the latest beta (probably released tomorrow) or to use the env var to enable support (see link above), then create a separate identity for which you don’t configure a wallet. If you then dfx canister create or dfx deploy, dfx will automatically use the cycles ledger

2 Likes