How to Restrict Specific Actions in an ICRC2 Ledger to Certain Principals?

I want to configure my ICRC2 ledger so that only specific principals are allowed to transfer, swap, sell, or buy my TokenX (ICRC2 token). How can I implement these restrictions to ensure that only authorized principals have access to these actions?

1 Like

You must create your own custom implementation of an ICRC1/ICRC2 ledger.

Instead of creating an ICRC1/ICRC2 ledger by copying the standard code as exemplified in our docs, it would require you to fork the original code, edit it with code for the restrictions (thinking out loud: a hashmap of the authorized principals and then checking the caller is one of the authorized principals in the hashmap), and deploy the code.

2 Likes

Should I fork all the repo or the part of icrc only that I want?

2 Likes

I want to make this whitelist to make my restrictions in my dapp and (mainly) outside my dapp like in nns and swap icp, so no one can receive tokens except the one who’s in whitelist , can this code help me make this or should I fork all the code of the ledger?