Pubnet RPC v2 (Beta) only: queryEvents is not served on the Pubnet or Testnet Stellar RPC endpoints. See the Stellar overview for how to create a Pubnet RPC v2 (Beta) endpoint.
This method will use 10 Compute Units.
Reference: Here
Parameters
A request is either a new query or a continuation. A new query usesminLedger, maxLedger, order and filters, each optional except as noted below. A continuation sends cursor in place of those fields. The cursor does not store limit or xdrFormat, so if you set either one, send it again with every continuation. Otherwise the defaults apply.
minLedger(number) - First ledger to scan, inclusive. Required whenorderisasc. Optional whenorderisdesc, where it defaults to2.maxLedger(number) - Last ledger to scan, inclusive. If omitted, anascscan follows new ledgers as they close and adescscan starts at the latest ledger.order(string) -asc(default) ordesc. Adescscan returns the newest events first, including within a single ledger.filters(array) - Optional. Fields inside one filter must all match. An event is returned if it matches any filter. Omit to match all events. Each filter sets at least one of:type(string) -contractorsystem.contractId(string) - One contract ID in strkey form (C...).topic0totopic3(string) - A base64-encoded XDRScValthat must equal the topic at that position. An omitted position matches any value.
cursor(string) - Thecursorfrom a previous response. Not allowed together with the new-query fields.limit(number) - Events per page, from 1 to 1000. Defaults to 100.xdrFormat(string) -base64(default) orjson, for thetopicandvalueof each event.
contractId, type and set topic position counts as one term.
Returns
eventsarray[object]typestring -contractorsystem.ledgernumber - Sequence number of the ledger that holds the event.ledgerClosedAtstring - Close time of that ledger, ISO 8601.contractIdstring - Contract that emitted the event. Empty for events without a contract.idstring - Unique event ID, in the same format and sort order as getEvents.transactionIndexnumber - Position of the transaction in the ledger, starting at 1.operationIndexnumber - Position of the operation in the transaction, starting at 0.txHashstring - Hash of the transaction.topicarray[string] - Topics as base64-encoded XDR, whenxdrFormatisbase64.valuestring - Event value as base64-encoded XDR, whenxdrFormatisbase64.topicJson/valueJson- Topics and value as JSON, whenxdrFormatisjson.
cursorstring - Send this to get the next page. Absent only whenscanStatusisCOMPLETE.scanStatusstring - How far the scan got:HAS_MORE- More of the range remains. Send the cursor.WAITING_FOR_LEDGERS- The scan reached ledgers that have not closed yet. Poll with the cursor about once per ledger close.OLDEST_REACHED- The range extends below the oldest ledger served.COMPLETE- The range is fully scanned.
scannedLedgernumber - Last ledger the scan fully covered. A page can end partway through a ledger, so before any ledger is fully covered the value isminLedger - 1for anascscan, or the top of the range plus 1 for adescscan (maxLedger, or the latest ledger whenmaxLedgeris omitted). That is why the example below shows ascannedLedgerone abovelatestLedger.oldestLedgernumber - Oldest ledger the node serves.latestLedgernumber - Latest ledger the node has committed.
limit, or none, and still return HAS_MORE. Use scanStatus to decide whether to keep paging. When scanning a sparse filter over full history, cap the number of requests in your client loop.
Invalid parameters return error code -32602 with error.data.reason set to invalid_params, ledger_out_of_range or cursor_malformed.
transfer event. topic0 is the symbol transfer encoded as base64 XDR.
cursor from the response: