Abstract class for the Provider. This class provides an interface for interacting with the blockchain.

Hierarchy (view full)

Constructors

Properties

kupoUrl: string
network: NetworkId
networkName: NetworkName
ogmios: Ogmios$1
confirmationTimeout: number = 20_000
plutusVersions: string[] = ...

Methods

  • Awaits confirmation of a transaction.

    Parameters

    • txId: TransactionId

      ID of the transaction to await confirmation for.

    • timeout: number = ...

      Optional timeout in milliseconds.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating confirmation status.

  • Evaluates a transaction.

    Parameters

    • tx: Transaction

      Transaction to evaluate.

    • additionalUtxos: TransactionUnspentOutput[]

      Additional UTXOs to consider.

    Returns Promise<Redeemers>

    A promise that resolves to the redeemers.

  • Gets unspent outputs for a given address.

    Parameters

    • address: Address

      Address to fetch unspent outputs for.

    Returns Promise<TransactionUnspentOutput[]>

    A promise that resolves to an array of unspent outputs.

  • Gets unspent outputs containing a specific asset.

    Parameters

    • address: Address

      Address to fetch unspent outputs for.

    • unit: AssetId

      Asset ID to filter by.

    Returns Promise<TransactionUnspentOutput[]>

    A promise that resolves to an array of unspent outputs.

  • Resolves the datum for a given datum hash.

    Parameters

    • datumHash: Hash32ByteBase16

      Hash of the datum to resolve.

    Returns Promise<PlutusData>

    A promise that resolves to the Plutus data.

  • Resolves the script deployment by finding a UTxO containing the script reference.

    Parameters

    • script: Hash28ByteBase16 | Script

      The script or its hash to resolve.

    • Optionaladdress: Address = ...

      The address to search for the script deployment. Defaults to a burn address.

    Returns Promise<TransactionUnspentOutput>

    • The UTxO containing the script reference, or undefined if not found.

    This is a default implementation that works but may not be optimal. Subclasses of Provider should implement their own version for better performance.

    The method searches for a UTxO at the given address (or a burn address by default) that contains a script reference matching the provided script or script hash.

    const scriptUtxo = await provider.resolveScriptRef(myScript);
    if (scriptUtxo) {
    console.log("Script found in UTxO:", scriptUtxo.input().toCore());
    } else {
    console.log("Script not found");
    }
  • Resolves unspent outputs for given transaction inputs.

    Parameters

    • txIns: TransactionInput[]

      Array of transaction inputs.

    Returns Promise<TransactionUnspentOutput[]>

    A promise that resolves to an array of unspent outputs.

  • Translate a unix millisecond timestamp to slot, according to the providers network

    Parameters

    • unix_millis: number | bigint

      Milliseconds since midnight, Jan 1 1970

    Returns Slot

    The slot in the relevant network

  • Serialize unspent outputs to JSON format.

    Parameters

    • unspentOutputs: TransactionUnspentOutput[]

      Unspent outputs to serialize.

    Returns Utxo

    the serialized unspent outputs.