Account Validation Pattern
Programming Model · Deep
The systematic set of checks every Solana program must perform on each account before processing an instruction: ownership check (verify account.owner matches the expected program), signer check (assert is_signer for privileged accounts), writable check (confirm is_writable for accounts being modified), PDA re-derivation (recompute the PDA from seeds and compare to the passed address), discriminator check (validate the first 8 bytes match the expected type), and key equality (confirm specific accounts match known addresses like the token program ID). Anchor automates these via its Account trait derive macro and constraint attributes.