How to specify a canister principal id as the minter for an icrc1_ledger_canister in dfx.json

I’m trying to figure it out how I can turn one of the canisters defined in dfx.json (accounts) as the minter (based on its principal) for my ledger ICRC-1 also defined in the same file. The goal is to mint some new tokens every time a new account is created.

The thing is: When I run dfx deploy, all the canisters defined in dfx.json are created so I cannot know the principal for the minter and, I cannot inject it as an init parameter for the icrc-1 canister.

Is this a correct approach / good practice?

Screenshot from 2024-09-26 21-09-37

Apart from that, is there any way to define env vars in the files injected through init_arg_file? Something like:

Screenshot from 2024-09-26 21-11-31

Best regards!

1 Like

You can define a custom build command which modifies/creates the init arg file. dfx deploy first creates all canisters, so if you run dfx canister id during the build step you will get back the id that canister will have