How to import an ic deployed canister in my project so it works with local deployment?

import RemoteCanister “ic:njgly-uaaaa-aaaah-qb6pa-cai”;

gives me a following error:

cannot import canister urls without --actor-idl

I know its possible to do it on IC network with actor(“njgly-uaaaa-aaaah-qb6pa-cai”), but that doesn’t work when deploying locally.

1 Like

Your local dev environment runs its own replica which doesn’t call out to the main network, so for now the solution is to deploy a version of the remote canister (or a mock canister with matching interface) locally and interact with that using the actor(“<canister_id>”) format.

Note it’ll get assigned a different canister id, shown in the terminal output when deploying, so you’ll need to use that id locally.

Some related details here:
https://forum.dfinity.org/t/calling-another-canisters-methods/473/5?u=ori
And
https://forum.dfinity.org/t/how-to-use-cowsay-project-in-my-project/6473/3?u=ori

2 Likes