Solana instructions › How Anchor instruction discriminators work

How Anchor instruction discriminators work

When an Anchor program handles a transaction, it has to know which instruction was called. It does that by reading an 8-byte prefix at the start of the instruction data and comparing it to a precomputed value for each instruction name.

The standard rule is public and stable: take the instruction name in snake_case, prefix it with global:, hash that UTF-8 string with SHA-256, and use the first 8 bytes. For the name initialize the preimage is global:initialize. For SetComputeUnitLimit the preimage would be global:set_compute_unit_limit — but Compute Budget is not an Anchor program, so that value would be a computed curiosity, not the tag the runtime uses.

Account types use a different prefix: account:<Name>, usually with the Rust struct name as declared (often PascalCase). The calculator on the instruction lookup can compute either.

A published IDL may include the 8-byte array explicitly. When our snapshot has that array, the page labels the discriminator as published. When we only have the instruction name, we may show a computed value and say so. Programs can also override the default namespace; a computed value is not a substitute for a published IDL or a confirmed on-chain instruction.

Related: How to tell which instruction a transaction called and Native program instruction indexes.

To see which instructions a confirmed transaction actually ran, paste its signature into the Rugsight transaction explainer.

Instruction lists and published discriminators come from solana-idls@1.2.1 (MIT) and, for the System Program, Compute Budget and Associated Token Account programs, from their public instruction enums (Apache-2.0). Snapshot date 2026-11-17. Programs can upgrade, so a live program may differ from this snapshot. Computed Anchor discriminators are the first 8 bytes of sha256("global:<snake_case_name>") and are labelled as computed.