How events work in Ralph
Events are declared at the contract level and emitted inside functions:emit writes an event to the chain. The event fields are stored in order and typed exactly as declared.
Get events for a contract
eventIndex maps to the declaration order in the contract source. 0 is the first declared event, 1 is the second, and so on. Use it to tell Withdraw events apart from Deposit events.
nextStart is the offset to pass on the next request. Always use it rather than calculating start + limit yourself the indexer may have gaps.
Get the total event count
Before paginating check how many events exist:start to count - 20.
Get events for a specific transaction
Get events for a block
Decode event fields
Fields are returned as typed values in declaration order. Map them back to your event definition:to, Field 1 → amount. There are no field names in the API response order is the only mapping.
Polling for new events
To watch for new events from a contract poll the count endpoint and fetch new events when it increases:nextStart:
Parameters reference
Next steps
Interacting with contracts
Execute state-changing functions
Reading contracts via API
View calls and state reads reference

