Hello, ICP developers!
I am pleased to announce a couple of new features in the Cycles Minting Canister (CMC):
1. Send ICP via ICRC Methods
You can now send ICP to the CMC via icrc1_transfer
and icrc2_transfer_from
. This unlocks approve+spend use cases (see the “Approve+Spend” section below).
Previously, only the (legacy) transfer
method was supported. This was because you had to use the memo
field of type nat64
. Whereas, the newer icrc*
transfer methods have a memo
field of type blob
.
CMC now considers these memo
fields equivalent up to 64-bit unsigned little endian conversion.
The CMC methods that require ICP, along with their associated blob
memo
s are as follows:
/* notify_create_canister */ blob "\43\52\45\41\00\00\00\00"
/* notify_top_up */ blob "\54\50\55\50\00\00\00\00"
/* notify_mint_cycles */ blob "\4d\49\4e\54\00\00\00\00"
2. Automatic Refund
If you send ICP to the CMC, but do not use one of the special memo values that CMC recognizes, then, you can call any of the notify_* methods, and the CMC will send the ICP back to the address that it came from (minus one ICP transfer fee). This can be used to “undo” mistakes.
Thanks!
We really hope everyone enjoys these new features. As always, your continued support of the Internet Computer is greatly appreciated!
ADDENDUM: Approve+Spend
Earlier, we said that approve+spend use cases are enabled by these enhancements. This section expands on that. Let us explain using an example.
- Alice calls
icrc2_approve
to authorize Bob to spend Alice’s ICP. - Bob transfers ICP belonging to Alice to the CMC by calling
icrc2_transfer_from
. - Bob calls
notify_mint_cycles
on the CMC. - CMC mints cycles, and those cycles belong to Bob.
In this way, Bob is able to get cycles using Alice’s ICP.
Note that Bob can allow Charlie to call notify_mint_cycles
, and in this alternative scenario, the cycles would end up belonging to Charlie (in step 4). The principal who is authorized to call notify_mint_cycles
is controlled by the CMC subaccount that Bob sends the ICP to.
Also note that other notify_*
methods can be used, not just notify_mint_cycles
. In each case, a different memo
would be required.