How to find out all the implemented methods in a canister

I install the canister via IC.install_code.
In the beginning everything is fine, but versions can be updated, how do I know all the methods implemented in this canister? Or let’s say I install an unfamiliar wasm code, how do I access it from the motoko code and get open methods to call?

Canisters can have their interface added as a ‘custom section’ of the wasm. dfx adds that automatically. You can then look at the interface through something like icscan. Example for a random canister: ICSCAN

I am aware of the above.
More details:
There is a wasm file: actor_v1.wasm
I updated the code generated by wasm actor_v2.wams; actor_v3.wams …
Added functions (interfaces) in the following actors. I understand that I can keep version control from the code and keep a simple list of new functions directly in the code. But I am specifically interested in whether there is an opportunity to find out all the open functions of the actor. Something like the Reflection of classes in other languages.

Sometimes, when referring to the canister from the command line, an error with a list of available interfaces popped up with an incorrect call. Now I am studying a wasm file that was not written by me. I need to know the list of his open methods. I want to solve this problem and several related

Is there a way to add a custom section to the wasm compiled from Motoko? For example via a dfx flag or dfx.json field?

GitHub - dfinity/ic-wasm: A collection of libraries and tools for transforming Wasm canisters running on the Internet Computer may help extract the sections.

Motoko adds ones for both candid interface and stable variable signature.

Plus there is a legacy, hidden hacky query method for querying the interface of a canister buy I don’t have the name handy.

1 Like


1 Like

Precisely!!! This is a great idea for future releases.

Not at the moment, but it’s just moved to an nearer-term feature we’d like to add. For the moment, I think this should be possible using GitHub - dfinity/ic-wasm: A collection of libraries and tools for transforming Wasm canisters running on the Internet Computer

1 Like

A great tool.
A few clarifications:

ic-wasm <input.wasm> -o <output.wasm> instrument

1)Converts unstable variables into stable ones? That is, my memory-unstable code can be converted to memory-stable and the data will be saved after updating the canister (consider a simple case.)?

2)Is there a way to fully disassemble in motoko file?

  1. No, it unfortunately won’t do that and it would be difficult to do without recompiling from source. Also, upgrading the canister would discard the unstable data before the code would get a chance to look at it.

  2. You mean disassembly from wasm target code to motoko source code? No, we don’t support that and there’s not enough information in the binary to do that.