What is "Custom Program Error 0xa2" in anchor?

My Anchor program spits out an error that looks like: custom program error 0xa2. What does this mean? Where can I learn what this error means?

1 Answer

This is Error: 162: 8 byte discriminator did not match what was expected.

That means anchor was expecting an account's data to start with a certain 8 bytes, but it didn't.

That could be because you passed in the wrong kind of account (so the first 8 bytes were totally wrong), or maybe because you're trying to use zero_copy and haven't actually written those bytes yet (need to use #[account(zero)] before you've run .load_init())

It also can happen if you're trying to reference an account from a program that wasn't originally written in Anchor, and now you're rewriting it in Anchor. You might need to write some custom serialization logic for this.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like