Possible to check if msg.caller is a canister, as opposed to a user?

I’m currently writing a function that needs to treat canister- and user-principals differently. How might one check if msg.caller is a canister?

2 Likes

Principal are generic identifiers for canisters, users and possibly other concepts in the future. As far as most uses of the system are concerned they are opaque binary blobs with a length between 0 and 29 bytes, and there is intentionally no mechanism to tell canister id and users ids apart.

This is from the Interface specification

8 Likes

Ah missed this - thank you.

2 Likes

i had the same problem and this solution also helped me

1 Like

Useful, thank you!
Useful, thank you!