@arkade-os/sdk Documentation - v0.4.0-next.8
    Preparing search index...

    Class ContractWatcher

    Watches multiple contracts for VTXO changes with resilient connection handling.

    Features:

    • Automatic reconnection with exponential backoff
    • Failsafe polling to catch missed events
    • Polls immediately after (re)connection to sync state
    • Graceful handling of subscription failures
    const watcher = new ContractWatcher({
    indexerProvider: wallet.indexerProvider,
    });

    // Add the wallet's default contract
    await watcher.addContract(defaultContract);

    // Add additional contracts (swaps, etc.)
    await watcher.addContract(swapContract);

    // Start watching for events
    const stop = await watcher.startWatching((event) => {
    console.log(`${event.type} on contract ${event.contractScript}`);
    });

    // Later: stop watching
    stop();
    Index

    Constructors

    Methods

    • Add a contract to be watched.

      Active contracts are immediately subscribed. All contracts are polled to discover any existing VTXOs (which may cause them to be watched even if inactive).

      Parameters

      Returns Promise<void>

    • Force a poll of all active contracts. Useful for manual refresh or after app resume.

      Returns Promise<void>

    • Remove a contract from watching.

      Parameters

      • contractScript: string

      Returns Promise<void>