getEvents - Stellar

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

Parameters

ParameterTypeDescription
startLedgerintegerThe first ledger to include
filtersarray(optional) Array of event filters
paginationobject(optional) Pagination options

Filter Object:

FieldTypeDescription
typestringEvent type: "contract", "system", or "diagnostic"
contractIdsarrayArray of contract IDs to filter
topicsarrayArray of topic filters

Request

bashcurl --location --request POST 'https://shared.eu-central-1.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"
}'

index.js

javascriptimport axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "getEvents",
    "params": {
        "startLedger": 2539600,
        "filters": [
            {
                "type": "contract",
                "contractIds": ["CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"]
            }
        ],
        "pagination": {
            "limit": 100
        }
    },
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data)))
    .catch(error => console.log(error));
pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "getEvents",
    "params": {
        "startLedger": 2539600,
        "filters": [
            {
                "type": "contract",
                "contractIds": ["CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"]
            }
        ],
        "pagination": {
            "limit": 100
        }
    },
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)
rustuse reqwest::header;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header(header::CONTENT_TYPE, "application/json")
        .body(r#"{
            "jsonrpc": "2.0",
            "method": "getEvents",
            "params": {
                "startLedger": 2539600,
                "filters": [
                    {
                        "type": "contract",
                        "contractIds": ["CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"]
                    }
                ],
                "pagination": {
                    "limit": 100
                }
            },
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

json{
  "jsonrpc": "2.0",
  "id": 8675309,
  "result": {
    "events": [
      {
        "type": "contract",
        "ledger": 200010,
        "ledgerClosedAt": "2025-06-30T07:27:13Z",
        "contractId": "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
        "id": "0000859036408881152-0000000003",
        "pagingToken": "0000859036408881152-0000000003",
        "inSuccessfulContractCall": true,
        "txHash": "d9e771ac73ec80503c7594f540d10ec068fb80981d11acea41aa193b7543c5ce",
        "topic": [
          "AAAADwAAAAh0cmFuc2Zlcg==",
          "AAAAEgAAAAAAAAAA6qNYcgGe/Zw2XRAUKPzIjtK2Cfp0eT8bn/BCJTcEq4s=",
          "AAAAEgAAAAGWF5MS3cqvdZjF5BY4yqI44bey/KmQmH9oF0gX3IIWuw==",
          "AAAADgAAAAZuYXRpdmUAAA=="
        ],
        "value": "AAAACgAAAAAAAAAAAAAAAF2UTIA="
      }
    ],
    "latestLedger": 320543,
    "cursor": "0000863490289963008-0000000010"
  }
}

Response Parameters

FieldTypeDescription
eventsarrayArray of event objects
typestringEvent type
ledgerintegerLedger sequence number
contractIdstringContract that emitted the event
topicarrayEvent topics (base64 XDR)
valuestringEvent value (base64 XDR)
latestLedgerintegerLatest 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 CodeError MessageCause
403ForbiddenMissing or invalid ACCESS-TOKEN
-32602Invalid paramsInvalid filter or pagination parameters