@arkade-os/sdk Documentation - v0.4.21
    Preparing search index...

    Interface OnchainProvider

    interface OnchainProvider {
        broadcastTransaction(...txs: string[]): Promise<string>;
        getChainTip(): Promise<{ hash: string; height: number; time: number }>;
        getCoins(address: string): Promise<Coin[]>;
        getFeeRate(): Promise<number | undefined>;
        getTransactions(address: string): Promise<ExplorerTransaction[]>;
        getTxOutspends(txid: string): Promise<{ spent: boolean; txid: string }[]>;
        getTxStatus(
            txid: string,
        ): Promise<
            | { confirmed: false }
            | { blockHeight: number; blockTime: number; confirmed: true },
        >;
        watchAddresses(
            addresses: string[],
            eventCallback: (txs: ExplorerTransaction[]) => void,
        ): Promise<() => void>;
    }

    Implemented by

    Index

    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, block time, and block hash

    • Fetch spendable onchain outputs for an address.

      Parameters

      • address: string

        Bitcoin address to query

      Returns Promise<Coin[]>

      Spendable onchain outputs for the address

      Coin

    • 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 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

      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 and invoke the callback when transactions are observed.

      Parameters

      • addresses: string[]

        Addresses to monitor

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

        Callback invoked when matching transactions are seen

      Returns Promise<() => void>

      Stop function that cancels the watch

      Implementations may use websockets, server-sent events, polling, or a hybrid strategy.

      getTransactions