Possible to query a canister for a list of its available public methods?

Use case: I want to see the list of all available public methods on any arbitrary deployed canister, and ideally any flags or other information needed to call them, like expected inputs and input format.

Basically something like dfx canister call canister_name --list-public-methods.

The DFINITY SDK docs show that dfx canister call with the --query flag can return info about the canister, but I’m not seeing any further details on it.

Is this possible?

The easiest way to check is to visit https://ic.rocks/principal/<canister-id> and then look at the candid declarations

1 Like

Good enough, thanks!

1 Like

A couple more options:

From dfx you can call Canlista for any listed canisters (see getCandid here):

dfx canister --network ic call kyhgh-oyaaa-aaaae-qaaha-cai getCandid '(principal "<canister_id>")'

For any arbitrary canister you can also search Canlista:

https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/search?s=<canister_id>

This will include Rust and C++ canisters if they’re listed, or any Motoko canister on the network.

2 Likes

You could also use the Candid interface (for Motoko canisters):

https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=<canister_id>
2 Likes