Skip to main content
Ralph contracts emit events to record activity on-chain. Events are immutable, indexed by the explorer, and queryable via the API without running contract code.

How events work in Ralph

Events are declared at the contract level and emitted inside functions:
Each 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:
To read the most recent 20 events set start to count - 20.

Get events for a specific transaction

Useful for confirming exactly which events a transaction emitted after submission.

Get events for a block

Use this when processing blocks sequentially fetch all events in a block in one request rather than per-transaction.

Decode event fields

Fields are returned as typed values in declaration order. Map them back to your event definition:
Field 0 → 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:
Store the count. On the next poll if the count has increased fetch from your last nextStart:
Poll no faster than once per 16 seconds that is the average block time per chain.

Parameters reference

Next steps

Interacting with contracts

Execute state-changing functions

Reading contracts via API

View calls and state reads reference