Interface Provider

Defines the contract for a blockchain data provider.

Implementations of this interface are responsible for fetching on-chain data, submitting transactions, and evaluating transaction costs.

interface Provider {
    confirmTransaction(txId: string, timeout?: number): Promise<boolean>;
    evaluateTransaction(
        tx: string,
        additionalUtxos?: UTxO[],
    ): Promise<Redeemer[]>;
    getName(): string;
    getNetworkMagic(): NetworkMagic;
    getParameters(): Promise<ProtocolParameters>;
    getRewardsBalance(rewardAccount: string | RewardAddress): Promise<bigint>;
    getUnspentOutputByNft(assetId: string): Promise<UTxO>;
    getUnspentOutputs(address: string | Address): Promise<UTxO[]>;
    getUnspentOutputsWithAsset(
        address: string | Address,
        assetId: string,
    ): Promise<UTxO[]>;
    resolveDatum(datumHash: string): Promise<string>;
    resolveUnspentOutputs(txIns: TxIn[]): Promise<UTxO[]>;
    submitTransaction(tx: string): Promise<string>;
}

Implemented by

Methods

  • Wait for a transaction to be confirmed on-chain.

    Parameters

    • txId: string

      Transaction id to confirm.

    • Optionaltimeout: number

      Optional timeout in milliseconds.

    Returns Promise<boolean>

    A promise that resolves to true if confirmed, otherwise false.

  • Evaluate a transaction to get its execution costs.

    Parameters

    • tx: string

      Transaction payload to evaluate.

    • OptionaladditionalUtxos: UTxO[]

      Optional extra UTxOs to consider.

    Returns Promise<Redeemer[]>

    A promise that resolves to a list of redeemers with execution units.

  • Gets the human-readable name of the provider (e.g., "Blockfrost").

    Returns string

    The name of the provider.

  • Get the current staking rewards balance for a reward account.

    Parameters

    • rewardAccount: string | RewardAddress

      Reward account address or bech32 string.

    Returns Promise<bigint>

    A promise that resolves to the balance in lovelace.

  • Find the single UTxO that holds a given NFT.

    Parameters

    • assetId: string

      NFT asset identifier.

    Returns Promise<UTxO>

    A promise that resolves to the UTxO containing the NFT.

  • List all unspent transaction outputs (UTxOs) controlled by an address.

    Parameters

    • address: string | Address

      Payment address. Address object or bech32 string.

    Returns Promise<UTxO[]>

    A promise that resolves to an array of UTxOs.

  • List all UTxOs for an address that contain a specific asset.

    Parameters

    • address: string | Address

      Payment address. Address object or bech32 string.

    • assetId: string

      Asset identifier (policyId + asset name hex).

    Returns Promise<UTxO[]>

    A promise that resolves to matching UTxOs.

  • Fetch an on-chain datum by its hash.

    Parameters

    • datumHash: string

      Hash of the datum.

    Returns Promise<string>

    A promise that resolves to the datum payload (hex-encoded CBOR).

  • Resolve concrete UTxOs for a list of transaction inputs.

    Parameters

    • txIns: TxIn[]

      Inputs to resolve.

    Returns Promise<UTxO[]>

    A promise that resolves to an array of UTxOs.

  • Submit a signed transaction to the network.

    Parameters

    • tx: string

      Transaction payload (hex-encoded CBOR).

    Returns Promise<string>

    A promise that resolves to the submitted transaction id.