Account updates using memcmp
memcmp Account Filters - Subscribing to Updates with Known Byte Patterns
memcmp
filters allow you to match specific portions of binary data within accounts, helping you include only those account updates that meet specific criteria. This makes them especially useful for targeting specific states or values in program-owned accounts. For instance, you can use a memcmp
filter to track liquidity pool balances, monitor token ownership, or identify program-specific flags. A memcmp
filter typically specifies three key parameters: offset
, which defines the starting byte position in the account data to compare; bytes
, the value to match at the specified offset; and Encoding (optional), which determines how the bytes are encoded, such as base64 or base58.
For instance, this subscribe request streams updates for Raydium pool accounts with a marketProgramId
equal to serum. The filter targets the marketProgramId
field of the account, ensuring updates are streamed only for matching accounts.
Last updated
Was this helpful?