How to check the status of a canister without owner?

In my case, first give up the ownership of a canister, then query its status, error will happen.

Is there any method to query a canister status without owner, or a further step, make the canister status public to anyone?

The canister itself can call ic0.canister_status(). So you can add a method to your canister that calls ico.canister_status() and returns the response; and call that.

Actually, if the canister is stopped or stopping, it won’t accept any more calls. And the status will be in the error message. So you can just call any method on your canister: if it succeeds, it’s Running; if not, the error message will tell you what state it’s in.

1 Like

@free, thanks for your info. after add the following code, it works as expected

#[ic_cdk::update]
async fn status () -> Result<CanisterStatusResponse, String>  {
    let call_result = canister_status(CanisterIdRecord {
        canister_id: ic_cdk::id(),
    })
    .await;

    match call_result {
         Ok((response,)) => Ok(response),  
         Err((code, message)) => Err(format!("Error code: {:?}, message: {}", code, message)), 
   }

}