What a discriminator is
Anchor tags every instruction, account, and event with the first 8 bytes of a SHA-256 hash. The program reads those bytes first to know which handler or type it is looking at.
Free tool
This Anchor discriminator calculator turns an instruction, account, or event name into its 8-byte tag. You get hex, a byte array, base58, and a Rust literal, with the exact string that was hashed.
No sign-up. Runs in your browser. Last reviewed by the Builderz team.
Everything runs in your browser. Nothing is sent anywhere.
Type a name to see its discriminators.
Anchor tags every instruction, account, and event with the first 8 bytes of a SHA-256 hash. The program reads those bytes first to know which handler or type it is looking at.
An instruction hashes "global:" plus the snake_case name, for example global:initialize. An account hashes "account:" plus the PascalCase type name. An event hashes "event:" plus the PascalCase type name. The same word gives three different values.
Anchor hashes the instruction name in snake_case and the account or event type name as written in Rust, which is PascalCase by convention. This tool normalises what you type the same way and shows the preimage, so transferTokens becomes global:transfer_tokens and vault_state becomes account:VaultState. If your Rust name breaks the convention, type it exactly.
In instruction data they are bytes 0 to 7, followed by the Borsh-encoded arguments. In an account they are the first 8 bytes of the account data, followed by the fields. Anchor 0.30 and later IDLs carry the values inline, so older IDLs and raw logs are where you need to compute them.
The hash runs in your browser with the Web Crypto API. Names are not sent to a server.
Newer Anchor versions let you set a custom discriminator with #[account(discriminator = ...)] or on an instruction. When you do, the default hash is not used. Read the value from the IDL or the source instead of computing it.
No. It is a type tag, anyone can compute it, and it only tells the program which layout to expect. Owner checks, signer checks, and seed checks still decide who is allowed to do what.
Native programs and Shank-based programs have no shared discriminator convention. Each one picks its own tag, often a single byte. This tool only covers the Anchor rule.
An event hashes "event:" plus the PascalCase name. Anchor writes those 8 bytes at the start of the event data in the program log or the self-CPI instruction, so an indexer can tell event types apart.
Beyond the tool
$10K-$40K. Book an intro call, or send a brief with what the tool showed you. We reply within one business day.
Acceptance in writing
Criteria agreed before build starts
Proposal in 48h
After a qualified scoping call
Change control
Scope, exclusions, and owners named