getEvents - Stellar

Example code for the getEvents JSON-RPC method. Complete guide on how to use getEvents JSON-RPC in GetBlock Web3 documentation.

This method returns contract events from the Stellar network based on filter criteria.

Parameters

Parameter
Type
Description

startLedger

integer

The first ledger to include

filters

array

(optional) Array of event filters

pagination

object

(optional) Pagination options

Filter Object:

Field
Type
Description

type

string

Event type: "contract", "system", or "diagnostic"

contractIds

array

Array of contract IDs to filter

topics

array

Array of topic filters

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getEvents",
    "params": {
        "startLedger": 2539600,
        "filters": [
            {
                "type": "contract",
                "contractIds": ["CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"]
            }
        ],
        "pagination": {
            "limit": 100
        }
    },
    "id": "getblock.io"
}'

Response

Response Parameters

Field
Type
Description

events

array

Array of event objects

type

string

Event type

ledger

integer

Ledger sequence number

contractId

string

Contract that emitted the event

topic

array

Event topics (base64 XDR)

value

string

Event value (base64 XDR)

latestLedger

integer

Latest available ledger

Use Case

The getEvents method is essential for:

  • Smart contract event monitoring

  • DApp state synchronization

  • Event-driven applications

  • Activity tracking

  • Notification systems

  • Analytics and indexing

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN

-32602

Invalid params

Invalid filter or pagination parameters

Last updated

Was this helpful?