let canisterB = actor ("canister_id") : actor {
service : (Text, Int, ....) -> async (Text);
//you can define as many services here.
};
//Calling
let t : Text = await canisterB.service(arg1, arg2);
//Make canisterB instance like above in any other canisterA like this.
Yes, it turns out the problem was class actor canisters can’t be imported with canister:, which is the only way I found the docs and examples made reference to:
By using the service pattern, it worked. In my case:
let icrc_token_canister = actor ("r7inp-6aaaa-aaaaa-aaabq-cai") : ICRCTypes.TokenInterface;
@Severin If you have any say in the docs / examples, I suggest making clear that
import AAA "canister:aaa";
does not and cannot work with class actors. I spent quite a while trying to make canister: work yesterday.
There seems to be guidance on how to create a new class actor canister from inside another canister but not on how to simply call a deployed class actor canister from another canister, eg how to achieve the last line here:
let icrc_canister = actor ("r7inp-6aaaa-aaaaa-aaabq-cai") : ICRCTypes.TokenInterface;
let token_symbol = await icrc_canister.icrc1_symbol();
In particular, no mention that canister: only works for certain types of canisters (non-class-actor canisters), which was the main cause for my confusion:
I assume the confusion would not arise if I had a deeper understanding of the complete IC but at least for me, it arose.
We just had a major redesign of the docs and there will be a lot more broken links. I just fixed the ones you pointed out, but please keep reporting them
Agree that its way too hard to find a simple example of doing intercanister call to a mainnet canister
Don’t even get me started on doing candid to motoko type translation