Filter a Starknet event whose account is marked as a key

Cairo event fields can be serialized into keys or data. Looking for a wallet address in the data array misses events where the contract deliberately made that field filterable.

Map the event ABI to keys and data

For a simple top-level event variant with the fields below, put its selector in key position zero and the account in the next key position. The u256 amount occupies two data felts. Check the emitting contract address as a separate filter.

#[key] account: ContractAddress
amount: u256
keys = [event_selector, account]
data = [amount_low, amount_high]

An event for account 0x123 with data [7, 0] reports amount seven for that ABI. A different contract can reuse the same event name, so matching only the selector does not identify the asset or its units.

Inspect nested event definitions

Components and nested enums can add selectors to the key sequence. A flat variant suppresses the enclosing variant selector. Derive the actual sequence from the deployed class ABI before choosing a positional RPC key filter. starknet.io The Cairo Programming Language