What does the error for A raw constraint was violated mean?

    errorCode: { code: 'ConstraintRaw', number: 2003 },
    errorMessage: 'A raw constraint was violated',

1 Answer 1


These are the types of constraints defined using this syntax #[account(constraint = <expr>)].

From the anchor documentation:

Constraint that checks whether the given expression evaluates to true.
Use this when no other constraint fits your use case.


#[account(constraint = one.keys[0].age == two.apple.age)]
pub one: Account<'info, MyData>,
pub two: Account<'info, OtherData>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.