I would like to send some tokens to account identifiers on an ICRC-2 token like what’s possible on the ICP ledger, but the ICRC2 and 1 as well, it only support the principals, where can I find the code for an ICRC-2 so maybe I can customize and add the function to transfer to an AID.
A few questions:
Why the current implementation doesn’t support transfering to account ids?
Would it be a good practice to add this function as I intend to do?
Principal + subaccount -> account ID is a one-way function. There is no way to go from an account ID back to the original principal without knowing the original account already. The ICRC ledgers all store tokens by principal + subaccount. If you try to transfer using only an account id, there is no way for the ledger to know which account to charge/credit.
The ICP ledger only stores account ids. It can offer ICRC-1/2 functions because it can convert to account ids. But it will never be able to support ICRC-3 because that requires Principal + subaccount representation