Search code examples
anchorsolanaanchor-solana

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


My Anchor program is giving me a Transaction simulation failed: Error processing Instruction 1: custom program error: 0xa7 with nothing useful in the logs.

How do I even begin to debug this?


Solution

  • Custom Program Error 0xa7 is Error: 167: The given account is not owned by the executing program.

    This might happen if you pass in an account that's expected to be owned by a program, but isn't.

    This can happen accidentally if you forget to set declare_id!(/* ... */) to the program id you're trying to hit.

    Consider logging the program id that you're using in your javascript client:

    console.log(program.programId)
    

    And then seeing if that matches the public key that's in your target/idl/yourprogram.json file.