Evan Conrad
Evan Conrad

Reputation: 4389

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?

Upvotes: 1

Views: 1267

Answers (1)

Evan Conrad
Evan Conrad

Reputation: 4389

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.

Upvotes: 5

Related Questions