OrbitDocs

Events

The events OrbitContract publishes, with their topics and data.

Each state-changing entrypoint publishes one event when it succeeds. The first topic is the event name as a Symbol, and the data is a tuple.

Preview. Events are in the contract source on main but not yet in the testnet deployment CAZBZBUW...CDYQNG. Until the next redeploy, index the token's transfer events instead.

EventPublished byTopicsData
vault_createdcreate_vault(vault_created, user, merchant)(token, amount_per_interval, interval_seconds)
funds_pulledpull_funds(funds_pulled, user, merchant)(amount_per_interval, timestamp)
batch_disbursedbatch_disburse(batch_disbursed, sender)(token, recipient_count, total_amount)

Fields

vault_created

PositionFieldTypeMeaning
topic 1userAddressSubscriber who signed
topic 2merchantAddressMerchant allowed to pull
data 0tokenAddressToken the vault is billed in
data 1amount_per_intervali128Raw units per cycle
data 2interval_secondsu64Minimum gap between pulls

It is published every time create_vault succeeds, including when it overwrites an existing vault for the same pair.

funds_pulled

PositionFieldTypeMeaning
topic 1userAddressSubscriber who was charged
topic 2merchantAddressMerchant who was paid
data 0amount_per_intervali128Raw units transferred
data 1timestampu64Ledger timestamp of the pull. This is the vault's new last_pull_timestamp

batch_disbursed

PositionFieldTypeMeaning
topic 1senderAddressTreasury that paid out
data 0tokenAddressToken paid in
data 1recipient_countu32Number of splits in the batch
data 2total_amounti128Sum of all split amounts, in raw units

One event covers the whole batch. For the amount each recipient received, read the token's transfer events in the same transaction.

Only on success

An invocation that fails reverts completely, including its events. A rejected pull (too early, allowance exhausted, balance too low) leaves no Orbit event, so detect failures from the transaction result. See contract errors.

Filtering

Filter on the contract id and the first topic. Because user and merchant are topics, a merchant can subscribe to only its own pulls:

const { events } = await server.getEvents({
  startLedger,
  filters: [{
    type: "contract",
    contractIds: [ORBIT_CONTRACT_ID],
    topics: [[
      xdr.ScVal.scvSymbol("funds_pulled").toXDR("base64"),
      "*",                                              // any user
      new Address(MERCHANT).toScVal().toXDR("base64"),  // this merchant
    ]],
  }],
});

On this page