I’m bit confused about the relationship between calling/import other actors in Motoko, here are some cases:
- Calling a constructor of actor and invoke function calls on them:
- I have an actor A which imports another actor B File with
import "ActorB";and invokes a constructor of B, in this case a new canister with actor B is created in a new subnet, right? Further calls to B from A can be simple function calls, because the previous constructor invocation returned a new actor B object with the correct canister-address right?
- How can I destroy this new created canister with actor B in code of canister A?
- Calling a different actor in a different canister (both canisters are in a single project)
- I have a dfx.json with two canisters (canister 1 with actor A and canister 2 with actor B)
- I can import actor B in actor A with
import ActorB "canister:ActorB";
- now I can directly call actor B from actor A because the build process somehow inject the canister-address of actor B into the code of actor A, right?
- Calling a different actor in a different canister (both canisters are in different projects)
- we have two canisters in different projects, so they are not part of the same dfx.json
- canister 1 with actor A and canister 2 with actor B
- now I can’t simply
import ActorB "canister:ActorB";, because these actors are in different projects right?
- how can I import now actor B in actor A in Motoko (with types of actor B visible in code of actor A), so I can call actor B from actor A and how is the address of actor B is injected into actor A in this case?
- Is it possible to deploy the same actor with the same code to different canisters, so that each of them store different state or possibly also the same state?