Getting exact same canister ID's for two separate projects locally and they share ledger funds as well

You’ll only want one replica instance (dfx start) running. You can run this from any of the projects and deploy to it from the others.

If you run dfx start in project A’s directory, then deploy from project A, B, C etc. they’ll all deploy to project A’s replica. All the local replica state will be stored in project A’s .dfx directory. The canister ids will still be stored in each project’s respective .dfx directory, but now they’re all deployed to one replica they’ll be given unique canister ids. (Edit)

For your ledger canister example, you can build it in its own project but run dfx start in your app’s project directory and deploy both your app and the ledger to that.

And as Joachim says if you later need to start clean, always deploying the canisters in the same order ensures they’re given the same canister ids they had before.

4 Likes