How can I call an actor method from another canister?

Let’s say I have two canisters with actors A and B respectively.
How can I call A.foo() from B.bar()?

How should I declare a foreign function from another actor to make it work?

4 Likes

Hi joinu, There isn’t support for multiple actors yet. But you can create and import modules, see some of enzo’s examples: https://github.com/enzoh/mo-qr

4 Likes

Hi, Ori. This is not what I’m trying to achieve.
Is there a way to say to the compiler: “I know that this function <canister_id>_A.foo() is gonna be there, when you’ll be deployed, trust me. Here is its signature …”?

1 Like

Thanks joinu. The support for multiple actors will broadly include messaging between them and capabilities, this isn’t in the current release but should be coming up soon for you.

3 Likes

@senior.joinu A good tutorial on the current state of this has been added here:
https://sdk.dfinity.org/developers-guide/tutorials/multiple-actors.html

5 Likes

You can begin to explore this in v0.4.13: https://forum.dfinity.org/t/release-notes-for-v0-4-13/377 but please note the documentation doesn’t reflect this just yet.

4 Likes

Thanks a lot, Ori! Great news.

3 Likes

A simple example here for you, just for reference: Calling another canister's methods

5 Likes