Polls the Soroban RPC for contract events and dispatches them to registered handlers.

All polling happens in a setInterval loop. Call destroy() to stop it and release all listeners.

const sub = new EventSubscriber({
contractId: 'C...',
rpcUrl: 'https://soroban-testnet.stellar.org',
pollingIntervalMs: 3000,
});

const unsub = sub.on('CAddressFunded', (evt) => {
console.log('Funded', evt.target, 'amount', evt.amount);
});

// Later…
unsub(); // stop this specific listener
sub.destroy(); // stop polling entirely

Constructors

Methods

  • Tear down the subscriber: stop the polling loop and remove all listeners. After calling destroy() this instance cannot be reused.

    Returns void

  • Total number of registered callbacks across all event names.

    Returns number

  • Remove all listeners for a specific event name.

    Parameters

    Returns void

  • Manually trigger a single poll. Useful in tests or for on-demand refresh.

    Returns Promise<void>