`inspect` or `canister_inspect_message`?

https://internetcomputer.org/docs/current/motoko/main/language-manual#inspect tells about the function inspect and https://internetcomputer.org/docs/current/motoko/main/message-inspection tells about the function canister_inspect_message. What is the difference and which of the two functions to use against cycles-drain attack?

inspect is the higher level function that’s exposed in Motoko when you write your canister. canister_inspect_message is the lower level function that needs to be exported in your canister’s Wasm (so when Motoko compiles the code it’ll put whatever you have in your inspect to a Wasm function called canister_inspect_message). If you look more carefully, the second link you shared mentions canister_inspect_message as a reference from the Interface spec where the method is formally specified.

What is the difference and which of the two functions to use against cycles-drain attack?

There’s no difference as I explained above, it’s essentially how Motoko exposes to you the lower level canister_inspect_message available on ICP.

1 Like