Im trying to improve the code for converting ICP into cycles, from doing a regular transfer
call and sending ICP to a canister, i’m now trying to do it through the icrc2_transfer_from
which is giving me an issue.
It seems that its not possible to set the required memo that is needed for triggering a certain action on the cycles minting canister. When i’m setting the memo
in the TransferFromArgs
it gets translated to an icrc1_memo
and keeps the original memo as memo: Memo(0)
thus making it impossible to use as intended.
let args = TransferFromArgs {
spender_subaccount: Some(Subaccount::from(user_principal).0),
from: Account {
owner: user_principal,
subaccount: None,
},
memo: Some(Memo::from(MEMO_TOP_UP_CANISTER)),
amount: Nat::from(icp_amount - ICP_TRANSACTION_FEE),
fee: None,
to: Account {
owner: MAINNET_CYCLES_MINTING_CANISTER_ID,
subaccount: Some(Subaccount::from(canister).0),
},
created_at_time: None,
};
block
Block {
parent_hash: Some([172...239]),
transaction: Transaction {
memo: Memo(0),
operation: Some(Transfer {
from: AccountIdentifier([81...227]),
to: AccountIdentifier([35...206]),
amount: Tokens { e8s: 4040002 },
fee: Tokens { e8s: 10000 }
}),
created_at_time: Timestamp { timestamp_nanos: 1730190187068204017 },
icrc1_memo: Some([0, 0, 0, 0, 80, 85, 80, 84])
},
timestamp: Timestamp { timestamp_nanos: 1730190187068204017 }
}