in-solana by Supanode

Anchor constraint errors

Anchor’s account validation layer rejected the transaction because one or more account constraints in the #[derive(Accounts)] struct were not satisfied.

Error codes reference

Code (hex)Code (dec)NameMeaning
0x7D02000ConstraintMutAccount must be mutable but is_writable is false
0x7D12001ConstraintHasOneAccount’s field does not match the expected account
0x7D22002ConstraintSignerAccount must be a signer
0x7D32003ConstraintRawCustom #[account(constraint = ...)] check failed
0x7D62006ConstraintOwnerAccount is not owned by the expected program
0x7D72007ConstraintRentExemptAccount is not rent-exempt
0x7D82008ConstraintSeedsPDA seeds do not derive to the expected address
0x7D92009ConstraintExecutableAccount is not an executable program
0x7DA2010ConstraintStateDeprecated
0x7DB2011ConstraintAssociatedAssociated account derivation mismatch
0x7DC2012ConstraintAssociatedInitAssociated init failed
0x7DD2013ConstraintCloseClose constraint violation
0x7DE2014ConstraintAddressAccount address does not match expected
0x7DF2015ConstraintZeroAccount discriminator is not zeroed (init expects empty account)
0x7E02016ConstraintTokenMintToken account mint mismatch
0x7E12017ConstraintTokenOwnerToken account owner mismatch

Most common errors and fixes

ConstraintHasOne (2001)

Your #[account(has_one = authority)] constraint failed. The authority field stored in the account’s data does not match the authority account you passed.

Fix: Pass the correct account that matches what is stored in the on-chain data.

ConstraintSeeds (2008)

The PDA derivation from the seeds in #[account(seeds = [...], bump)] does not match the account address you passed.

Fix: Verify your PDA derivation uses the same seeds and program ID. Check that you’re using the canonical bump.

ConstraintSigner (2002)

The account marked with Signer or #[account(signer)] did not sign the transaction.

Fix: Add the account as a signer when building the transaction.

FAQ

How do I decode the hex error code? Convert the hex after 0x to decimal: parseInt("0x7D1", 16) gives 2001 → ConstraintHasOne.

Where are Anchor error codes defined? Framework errors are in the anchor_lang::error::ErrorCode enum. Custom program errors start at 6000 (0x1770).

What is the difference between constraint errors (2000s) and account errors (3000s)? Constraint errors (2000–2999) are from #[derive(Accounts)] validation. Account errors (3000–3999) are from account deserialization and initialization failures.

Error text variants

  • Anchor constraint error
  • ConstraintMut
  • ConstraintHasOne
  • ConstraintSigner
  • ConstraintOwner
  • ConstraintSeeds
  • custom program error: 0x7d0

Updated: