2

How can I modify this Anchor tutorial code in a way so when any non-authority wallet tries to update the count variable it will give a message with an error like only owner can modify the value?

1 Answer 1

3

First, you need to create an error, the message will be sent when the error is thrown

#[error_code]
pub enum ErrorCode {
    #[msg("This is an ERROR!")]
    MyCustomError,
}

then in your instruction

if something_is_wrong {
    return Err(error!(ErrorCode::DrawAlreadyOffered));
}
1
  • That's another question that needs to have a seperate post. Please open another post, thank you :))
    – vicyyn
    Commented Aug 23, 2022 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.