I am building a simple ICRC 1 Token deployer so that new ICP users can deploy their tokens easily without bothering themselves with tools like dfx.
but i am facing certain problems :
Dynamic deployment of canisters require cycles. These cycles come from the canister that is triggering the deployment.
Is there any way to accept ICP from users convert them to cycles, top up the canister triggering the deployment and then deploy the canister in motoko?
That’s a cool and much-needed dapp!
You can use the Cycles Minting Canister (CMC) to burn ICP for cycles. The CMC also allows the creation of a new canister from ICP directly.
To convert ICP to cycles, you need to send ICP with a specific memo to the CMC and notify the CMC about the payment. You can refer to the code in the
dfx ledger top-up command: sdk/src/dfx/src/commands/ledger/top_up.rs at master · dfinity/sdk · GitHub
In addition, here’s the Candid Interface of the CMC: ic/rs/nns/cmc/cmc.did at master · dfinity/ic · GitHub
It may be helpful to take a look at GitHub - icdevsorg/axon: DAO in a box. Each axon that is deployed gets its own ICRC1 token. Hopefully, in the coming weeks, I’ll have some time to update it to add ICRC2 and 3 as well. We take pull requests and adding a way to fund cycles would be amazing.