Using ICRC_2: how to

Hi all,

I’ve been reading up on ICRC-1 and ICRC-2 and I have to say I’m still a bit confused as to what I need to do in order to use ICRC-2.

The documentation says:

To interact with ICRC-2 locally, you will need to deploy the ICRC-1 ledger canister locally. You can learn how to do that here.

But when I try to deploy icrc1_ledger_canister locally, it get asked to provide a token symbol, whereas I don’t want to create a token, only make ICP recurring payments…

What am I missing here?

Also:

  • Do I need to locally deploy the icp_ledger_canister as well?
  • When I deploy my app in production, I won’t need those canisters, right? (as they already exist on the IC ? but then do I need to provide their id?)

Any information welcome :smiley:

Cheers!

To confirm, you only want to make reoccurring payments of ICP, not launch your own token on ICP (or make reoccurring payments of your own token on ICP)?

Exactly! Only ICP, no new token.

Got it, what programming language are you using? I can send good examples on how to implement.

Yes, you will not need to deploy a new ICRC-1 canister with the ICRC-2 extensions.

1 Like

You got it right, On the Mainnet, all of those token canisters are deployed and there is no need to redeploy any token canister(in your case ICP icrc2 canister). You can simply provide the icp canister id which is “ryjl3-tyaaa-aaaaa-aaaba-cai” and start making calls to it.
But on your local environment since those token canisters are not deployed(They don’t exist in your PC), you have to deploy your token casniter.
If you dont want to deploy a token locally or it’s complicated, you can also test your app on Mainnet without paying any cycles for canister deployment, simply by using playground environment which allows you to deploy a temporary canister for only 20 minutes to the main net IC.

1 Like

I’m using Motoko. Thanks a lot :pray:

So does that mean the ICRC2 methods are available on that canister?

Ah, I didn’t know that, thanks! I’ll definitely try it.

Do you know about any documentation on how to answer those questions?


I guess I should be using values found in this command…

dfx deploy --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister --argument "
  (variant {
    Init = record {
      minting_account = \"$MINTER_ACCOUNT_ID\";
      initial_values = vec {
        record {
          \"$DEFAULT_ACCOUNT_ID\";
          record {
            e8s = 10_000_000_000 : nat64;
          };
        };
      };
      send_whitelist = vec {};
      transfer_fee = opt record {
        e8s = 10_000 : nat64;
      };
      token_symbol = opt \"LICP\";
      token_name = opt \"Local ICP\";
    }
  })
"

…or maybe using this command will automatically add the canister to my dfx.json file?

So does that mean the ICRC2 methods are available on that canister?

Yes, all the ICRC1 as well as ICRC2 methods are available on ICP token canister.

1 Like

So by running the command you’ve shared, it will create a token canister on your local machine with the canister id “ryjl3-tyaaa-aaaaa-aaaba-cai”, which is the same canister id as ICP on main net IC.
If that is your intention is to simulate ICP token on your local machine you can run the same command that you’ve shared.
As soon as you run that command, you will have a token on your local network called LICP(local ICP) with “ryjl3-tyaaa-aaaaa-aaaba-cai” as ID, and you can use this token for testing purposes.
Having said that, all the ICRC1 and 2 methods will be included in that.

1 Like

Hello @marcpp,

You should connect with @appic on their DCA solution. Here is their code base.

@asjn3e is a core developer and seems to have walked through some of the code!

3 Likes