Verifying ICRC2 Transfers in Canisters

Hey folks, I have a question about using ICRC2 transfers in a canister and whether we need to verify the transaction after calling the transfer.

On our canister, we have the following transfer function:

await ICRC.service(Constants.CKBTC_Canister).icrc2_transfer_from({
  spender_subaccount = null;
  from = _accountFactory(from);
  to = _accountFactory(to);
  amount;
  fee = ?fee;
  memo = ?memo;
  created_at_time = null;
});

After calling this, if the response is #Ok, do we just assume the transfer went through and don’t need to check the transaction further?

Should I be calling get_transaction or a similar method to check that the funds were actually transferred. I guess it’s slower but more secure.

So, my question is: Should we be adding a call to verify the transfer after the transfer_from? Have others encountered issues where the transfer didn’t go through? Any insights would be appreciated!

Thanks in advance!

After calling this, if the response is #Ok , do we just assume the transfer went through and don’t need to check the transaction further?

Yes, if the ledger complies with the ICRC-2 standard (and thus ICRC-1), this means the transaction indeed has taken place and recorded in the block chain.

The #ok result also includes the index at which the transfer has been recorded in the block chain, this could be stored and used as future reference to lookup the transaction.

Should we be adding a call to verify the transfer after the transfer_from ?

This shouldn’t be needed, but as mentioned above, the block index returned in the #ok result can be used at any later point in time to see the transaction details. This means that your dapp doesn’t have to store all transaction details itself, it can look these up with the block index.

1 Like