A couple of new CMC features: ICRC1 memo, and automatic refunds

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 memos 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.

  1. Alice calls icrc2_approve to authorize Bob to spend Alice’s ICP.
  2. Bob transfers ICP belonging to Alice to the CMC by calling icrc2_transfer_from.
  3. Bob calls notify_mint_cycles on the CMC.
  4. 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.

7 Likes

nice new features thanks ser

is the fee really this high? :thinking:

No, the fee is 0.0001 ICP, but the CMC is not allowed to mint ICP and it has to pay for the transfer somehow :person_shrugging:

Sorry, what I meant is “1x ICP transfer fee”. I did NOT mean that the fee is 1 ICP!

1 Like