Solana IDL reference › How to find memcmp offsets for getProgramAccounts
getProgramAccounts returns every account owned by a program. A memcmp filter keeps only accounts whose data has the given bytes at a given offset, and dataSize keeps only accounts of an exact length. Both need the byte layout of the account.
Anchor accounts begin with an 8-byte discriminator: by default the first 8 bytes of sha256("account:<AccountName>"); Anchor 0.30+ IDLs publish the bytes. A memcmp at offset 0 with those 8 bytes (base58-encoded in the bytes field) selects one account type. Native programs such as SPL Token have no discriminator; filter them by dataSize instead (165 for a token account, 82 for a mint).
Borsh, the default Anchor serialization, writes fields in order with no padding. The offset of a field is the discriminator length plus the sizes of all earlier fields: u8/bool 1, u16 2, u32/i32 4, u64/i64 8, u128 16, Pubkey 32, [T; N] N × size(T). A nested struct is the sum of its fields. SPL's COption<T> is a 4-byte tag plus T, always full size.
Vec, String and Option take a different number of bytes per account (a 4-byte length, or a 1-byte tag with or without the value), so fields after them do not have one fixed offset. Put fields you filter on before them, or filter on something earlier.
Zero-copy (#[account(zero_copy)], bytemuck) accounts are raw memory images. With repr(C, packed) there is no padding. With plain repr(C) the compiler pads fields to their alignment, so well-designed zero-copy structs add explicit padding fields. Rugsight's pages only show offsets where every field is naturally aligned or the struct is packed.
| Account | Field | Offset | Account size |
|---|---|---|---|
| SPL Token Token account | owner | 32 | 165 |
| SPL Token Token account | mint | 0 | 165 |
| Orca Whirlpools Whirlpool | tokenMintA | 101 | 653 |
| Raydium CPMM (CP Swap) PoolState | token_0_mint | 168 | 637 |
| Raydium AMM V3 (CLMM) PoolState | token_mint_0 | 73 | 1544 |
| Meteora DLMM LbPair | token_x_mint | 88 | 904 |
| Raydium AMM V4 AmmInfo | coinMint | 400 | 752 |
| Pump.fun Bonding Curve BondingCurve | creator | 49 | 81 |
Each row links to the full layout with a ready filter. Sizes are from the 2026-11-17 snapshot; programs can add fields in upgrades, so prefer a discriminator filter over dataSize when a program may have resized an account.
All programs in the IDL reference · Explain a transaction
Data: solana-idls@1.2.1 (MIT, © Obsidian Protocol) and SPL Token / Token-2022 state layouts (Apache-2.0), snapshot 2026-11-17. Programs can upgrade and an IDL snapshot can lag the deployed program, so check important offsets against current account data.