@arkade-os/sdk Documentation - v0.5.0-rc.11
    Preparing search index...

    Class EsploraProvider

    Implementation of the onchain provider interface for esplora REST API.

    const provider = new EsploraProvider("https://mempool.space/api");
    const outputs = await provider.getCoins("bcrt1q679zsd45msawvr7782r0twvmukns3drlstjt77");

    Implements

    Index

    Constructors

    • Parameters

      • baseUrl: string = ...
      • Optionalopts: { forcePolling?: boolean; pollingInterval?: number }
        • OptionalforcePolling?: boolean

          Force polling even when websocket transport is available.

        • OptionalpollingInterval?: number

          Polling interval in milliseconds.

      Returns EsploraProvider

    Properties

    forcePolling: boolean
    pollingInterval: number

    Methods

    • Broadcast a single transaction or a 1P1C package.

      Parameters

      • ...txs: string[]

        One or more raw transaction hex strings

      Returns Promise<string>

      Broadcast transaction id

      Error if the broadcast request fails or the package shape is invalid

    • Fetch the current chain tip.

      Returns Promise<{ hash: string; height: number; time: number }>

      Current chain height, median-time-past, and block hash

      time is the tip's median-time-past, not the header's own nTime. BIP-113 evaluates seconds-typed OP_CHECKLOCKTIMEVERIFY / OP_CHECKSEQUENCEVERIFY against MTP, which lags the tip by roughly an hour; the header time may sit two hours ahead of it. An implementation returning the header time calls a timelock mature before the network does — surfacing as a broadcast the node rejects, not as a bug here.

    • Fetch the current fastest fee rate estimate.

      Returns Promise<number | undefined>

      Fee rate in sats/vB, if available

      Implementations may return undefined when the backing service does not expose a usable fee estimate.

    • Fetch the raw wire-format bytes of a transaction.

      Parameters

      • txid: string

        Transaction id to fetch

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Serialized transaction bytes

      Error if the transaction is unknown to the backend

      Needed to carry a boarding or commitment tx as a PSBT prevout field — those have no off-chain source, so the indexer cannot serve them.

    • Fetch outspend information for every output in a transaction.

      Parameters

      • txid: string

        Transaction id to inspect

      Returns Promise<{ spent: boolean; txid?: string }[]>

      Per-output spend status information. txid (the spender) may be absent even when spent is true: some Esplora deployments (e.g. mempool.arkade.sh) omit it from /outspends.

      getTxStatus

    • Fetch confirmation status for a transaction.

      Parameters

      • txid: string

        Transaction id to inspect

      Returns Promise<
          | { confirmed: false }
          | { blockHeight: number; blockTime: number; confirmed: true },
      >

      Confirmation status and block metadata when confirmed

      getTxOutspends

    • Watch a set of addresses over the explorer's WebSocket, degrading to HTTP polling whenever the socket is unavailable and returning to the socket as soon as it can be re-established.

      Concurrent calls covering the same address set share one transport. The returned function releases this subscription only; the transport is torn down when the last subscriber releases it. Calling it more than once is a no-op.

      Parameters

      • addresses: string[]

        Addresses to monitor; order is not significant

      • callback: (txs: ExplorerTransaction[]) => void

        Invoked with transactions seen after the watch started

      Returns Promise<() => void>

      A function releasing this subscription

      The HTTP fallback fetches full address history per address per cycle, which is dramatically more expensive than the socket — so callers should release watches they no longer need rather than relying on sharing.

      waitForIncomingFunds for the cancellation-aware wallet-level helper