ICRC-2/ICRC-103 for ICP ledger canister. Revoke all allowances

Good afternoon. I’m trying to understand the ICRC-2/ICRC-103 standard and I’ve run into some questions.

For all SNS tokens there is an icrc103_get_allowances method, which returns a list of accounts (principal + subaccount), and it is possible to revoke an allowance by passing a zero allowance for a specific account.
However, the ICP ledger does not have such an interface.

If I use get_allowances for ICP, I get a list of addresses (hashes of the principal + subaccount), and with this data I have no way to revoke all allowances for my account — icrc2_allowance still requires an account (principal + subaccount), which of course cannot be derived from a hash.

Is it possible that I’m missing something?
Is there any way to obtain all allowances for my principal and then revoke them on the ICP ledger?

Thanks

Hi @Oleksii ,

For the ICP ledger it is not possible to obtain the allowances of a principal since the ledgers itself does not keep the information about which account belongs to which principal.

There, you can remove allowances on a per account basis using the remove_allowance method.

See the last message in this thread for a discussion: https://forum.dfinity.org/t/standard-for-managing-icrc-2-approvals-a-challenge-for-the-icp-ledger/32997/20

Thank you. I’m getting a list of textual identifiers in get_allowances, but to execute remove_approval I need spender : blob.
How can I convert to_spender_id : text into spender : blob?

Is it sufficient to simply use AccountIdentifier.toUint8Array …. blob, or do I need to perform any additional steps to convert the text response into a blob request?

I assume you are using javascript? I haven’t used js to interact with IC, but I guess it could work. I would test it first, though. You can use the TESTICP ledger: https://dashboard.internetcomputer.org/canister/xafvr-biaaa-aaaai-aql5q-cai There is also a faucet where you can get TESTICP tokens for testing: https://nqoci-rqaaa-aaaap-qp53q-cai.icp0.io/

Thank you. I’ve already tested it. It’s sufficient to use AccountIdentifier.fromHex(spenderPrincipalId).toUint8Array(). This is a bit misleading. It’s unclear why this decision was made — to use one type for the response and then convert the same data to another type for the request. But it works, so thanks for that :slight_smile: