Setting up canister envrionments

I have a prod and staging environment on my IC project. Some of the canisters in my project are dependant on one another.

So lets say i have a storage canister and a trading canister the trading canister needs the canisterID of the storage canister I can either hard code both the prod and staging canister id of the storage canister into my trading canister and tell it which one to use depending on a deployment argument e.g. environment which can be a variant of either staging or prod…

or i could pass the canister ID as a deployment argument

Has anyone found a nicer way to do this using .env or something idk. Just looking for inspiration I can’t be the only one with this issue.

There is ic-cdk-bindgen, which can do some of the work. There is a toy project here from which you can copy, or this and this PR where I included it in a live project recently.

It’s currently underdocumented, but maybe you can figure it out?