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) | Name | Meaning |
|---|---|---|---|
| 0x7D0 | 2000 | ConstraintMut | Account must be mutable but is_writable is false |
| 0x7D1 | 2001 | ConstraintHasOne | Account’s field does not match the expected account |
| 0x7D2 | 2002 | ConstraintSigner | Account must be a signer |
| 0x7D3 | 2003 | ConstraintRaw | Custom #[account(constraint = ...)] check failed |
| 0x7D6 | 2006 | ConstraintOwner | Account is not owned by the expected program |
| 0x7D7 | 2007 | ConstraintRentExempt | Account is not rent-exempt |
| 0x7D8 | 2008 | ConstraintSeeds | PDA seeds do not derive to the expected address |
| 0x7D9 | 2009 | ConstraintExecutable | Account is not an executable program |
| 0x7DA | 2010 | ConstraintState | Deprecated |
| 0x7DB | 2011 | ConstraintAssociated | Associated account derivation mismatch |
| 0x7DC | 2012 | ConstraintAssociatedInit | Associated init failed |
| 0x7DD | 2013 | ConstraintClose | Close constraint violation |
| 0x7DE | 2014 | ConstraintAddress | Account address does not match expected |
| 0x7DF | 2015 | ConstraintZero | Account discriminator is not zeroed (init expects empty account) |
| 0x7E0 | 2016 | ConstraintTokenMint | Token account mint mismatch |
| 0x7E1 | 2017 | ConstraintTokenOwner | Token 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: