canister_status
is only available to controllers of the canister. I believe you want to programmatically get the module hash of any third-party canister. The options are:
-
With dfx:
dfx canister --ic info <canister id>
-
From your own code running outside the IC: You have to read from the state tree which is a bit inconvenient. See this forum thread where I asked the same question: How does dfx call canister_info and canister_status?
@Severin gave some links to code examples there (Rust and js). You can also see how the frontend on https://history.ic0.info does it here:useReadState
function -
From canister code: As @Severin mentioned above, call the management canister function
canister_info
. But it only works from canister code, not from outside the IC.