Definition
A short prefix stored at the start of an account or instruction that identifies its type. Anchor adds discriminators automatically to prevent one account type from being passed in place of another.
Why it matters
Without a type check, an attacker can pass an account of one type where another is expected, a bug known as type cosplay. Anchor handles this by default; native programs must implement it themselves.
What to check
- In native Rust code, ask how account types are told apart.
- Ask how discriminators are handled when account layouts change in an upgrade.
Related terms
- AccountThe unit of storage on Solana.
- AnchorThe most widely used framework for writing Solana programs in Rust.
- Native Rust programA Solana program written without the Anchor framework, handling account parsing and validation by hand.
Guides
Get an indicative price range and timeline for auditing your Solana programs, then compare verified auditors.
Estimate your audit cost →