Is there a way to set the canister id to be deployed before calling dfx deploy …? so that when I do some local tests of the ledger or ckbtc, etc I can use the same canister id in my tests and mo files?
I try doing this by presetting my canister_ids.json i.e.
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed while trying to install all canisters.
Failed to install wasm module to canister 'ckbtc'.
Failed to install wasm in canister 'mc6ru-gyaaa-aaaar-qaaaq-cai'.
Failed to install wasm.
The replica returned an HTTP Error: Http Error: status 404 Not Found, content type "", content: Canister mc6ru-gyaaa-aaaar-qaaaq-cai not found
or it sets the canister id in .dfx/local/canister_ids.json to a completely new canister id
Not sure because I am no dfx expert and no direct answer but, canister ids deployed locally are predictable in the sense that if you deploy your canisters always in the same order, you will always get the same canister ids.
So that’s what I do. I either document the order in a README.md or create a script that deploys the canisters and that way I can use the same canister id in my code for local dev.
appreciate the input, but yea I wanted it so that if I deploy a local icp ledger or local ckbtc ledger on a test server, if I move over to mainnet I didnt want to have to go to all my mo files and change the ids. This is useful to know though.
canister ids deployed locally are predictable in the sense that if you deploy your canisters always in the same order, you will always get the same canister ids.
Albeit, for some reason for the one of my canisters I was able to actually change the canister id in .dfx/local/canister_ids.json and it worked. so yea idk
Hope someone with better dfx can answer here. For what it’s worth and if it can help too maybe, there is also a thread about “env files for Motoko” ENV variables for motoko builds - #8 by paulyoung
@paulyoung and @peterparker but thats basicallly to specify an already existing canister id on the specific network. Not if I wanted to create a canister with a specific id
Because I’m doing something where I want to update some hashmaps that use the canister-id’s/canister-principals as keys, I want to make my local canisters have the canister-ids of the already existing network canisters. You get what I mean?
I do understand thats for the specifying the interface based on either local or ic network but its not for the principal.
Caused by: Failed while trying to deploy canisters.
Failed while trying to install all canisters.
Failed to install wasm module to canister 'ckbtc'.
Failed to install wasm in canister 'mc6ru-gyaaa-aaaar-qaaaq-cai'.
Failed to install wasm.
The replica returned an HTTP Error: Http Error: status 404 Not Found, content type "", content: Canister mc6ru-gyaaa-aaaar-qaaaq-cai not found
If I swap one of the autogenerated ones with a custom canister it works. I.e. like if I created 5 canisters and the first one in the canister_ids.json was ryjl3-tyaaa-aaaaa-aaaba-cai and I set the fifth one to that id, it will work. But not a new fresh id.
Best guess: The canister is not created yet, so there’s no way to install anything to it.
As for specifying specific IDs for local canisters: we’re pretty close to having this, now it’s a matter of prioritisation. EDIT: I misread what this PR does If someone wants to cut the line by making a PR: @mraszyk did all the hard work in this PR, now it’s just a matter of exposing the parameters in a sensible manner.
The interface to support is described in the spec.
@Severin the link that you provided seems to be broken. I’m also looking for a way to define a local canister id for testing of canisters in local development. Do you have an updated reference for this?
EDIT: just found that this is possible with the deploy command directly and setting the flag --specified-id <canister-id> (see reference description). Would still love to have an option to define it in dfx.json or canister_ids.json for the local deployment.