approve from an owner, a router deposit or
swap for a trader, a confidential token register for a holder. Those events
are filed under the emitting contract, so account activity does not return them.
The contract-event topic index finds them by address, across all of history.
Set these once in your terminal. The sample values are real Testnet data, so
the read examples return real results.
Find events that name an address
Everyapprove event that names $ACCOUNT in topic 1, 2 or 3, in any contract:
Search one contract
To search a single contract, addtopic1, topic2 or topic3 to contract
activity. Here $ACCOUNT is the spender, topic 2 of the token’s approve
events:
topicN, contract activity needs no ledger window. Without one, it is
plain contract activity and still requires since_ledger or a cursor.
Parameters
Both routes default to
desc, accept limit up to 1000 (default 10) and
return the standard snapshot-bound page. Each record is
the unchanged event body with paging_token and
rpc_event_id. These return 400: two topicN parameters, a position other
than 1 to 3, name on contract activity without a topicN, and direction or
include_fees (account-activity filters).
Credits
On Mainnet both routes cost 1 credit per started 100 records, like account activity, so a full 1000-record page costs 10 credits. Testnet requests cost 0 credits and count toward the daily Testnet cap of 10,000 requests. See credits.What is indexed
Only top-level topics 1 to 3 are indexed; topic 0 is the event name. Values insidedata, and addresses nested in a topic vector or map, are not searched.
Matching uses the exact topics_xdr, not the rendered JSON. Account (G),
contract (C), claimable balance (B) and liquidity pool (L) addresses match
by StrKey. A muxed (M) address in a topic matches both its M address and its
base G account. An event that names the address in two positions appears once.
Coverage and errors
The topic index covers history from ledger 3 to the published snapshot on both networks.
See errors for
busy, query_timeout and the other shared codes.
Compared with RPC event queries
Stellar RPCgetEvents keeps a short retention window, and an indexer that
scans ledger ranges needs many sequential scans to find one address across
years of history. The topic index is keyed by address: one request returns the
next page of matching events from any point in history.
Each contract_event record carries rpc_event_id, the RPC event id of the
same event. You can also match on tx_hash, ledger, contract_address and the
exact topics_xdr/data_xdr, which an RPC event object carries as txHash,
ledger, contractId, topic and value.