Read events from a ledger
Contract activity needs a start ledger (since_ledger). Ascending order reads
oldest first:
kind
token_transfer) when the contract is a token. type is the event name
(topic 0), topics and data are decoded from XDR, and the exact
topics_xdr and data_xdr are included too.
Keep following new events
The follower starts at the current tip and polls. A request whosesince_ledger is past the newest published ledger returns an empty, complete
page whose scanned_through_ledger is that newest ledger, so one cheap call
finds where “now” is.
scanned after each round in your database, as in
Sync history to a database, so a restart continues
where it stopped. Deduplicate on (network, id).
get retries rate_limited, busy, index_not_ready and unavailable after
Retry-After, at most 5 times. It stops on a Retry-After over 60 seconds (the
daily Testnet cap, which resets at 00:00 UTC) and on query_timeout, which must
not be repeated unchanged: lower limit and restart from the saved ledger.
Only events that name an address
Passtopic1, topic2 or topic3 with a G..., C..., B... or L...
address to get only the contract’s events with that address at that topic
position, from the whole history and without a start ledger. Add name to
match one event name. In this pool the user is topic 3:
topicN per request. To find an address’s events across every
contract, use GET /accounts/{id}/contract-events.
The follower above works with a topic filter too: add the same parameters to
each request.
Credits
On Testnet the follower is free: it costs 0 credits, and its 2,880 requests a day (one poll every 30 seconds) count toward your daily Testnet cap of 10,000 requests. On Mainnet:
Polling every 30 seconds costs at least 14,400 credits a day on plain contract
activity, about 432,000 a month. That is more than the Free plan’s 250,000
(used up in about 17 days, then
402), and fits Starter. With a topic filter
the same follower costs about 86,400 a month. To spend less, poll less often or
use a webhook with contract_addr, which pushes each
event for 1 credit per delivered event. See Limits and credits.
Next
- Contract events by address: topic index rules and coverage.
- Event fields: every record field.
- Errors:
topic_coverage,query_timeoutand retries.