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

Hierarchy (view full)

Constructors

  • Constructor to initialize Kupmios instance.

    Parameters

    • kupoUrl: string

      URL of the Kupo service.

    • ogmios: Ogmios$1

    Returns Kupmios

Properties

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

Methods

  • Awaits confirmation of a transaction.

    Parameters

    • txId: TransactionId

      ID of the transaction to await confirmation for.

    • Optionaltimeout: 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.

  • Get the slot config, which describes how to translate between slots and unix timestamps TODO: this is brittle; in theory this should work with the era histories; also, networkName is awkward

    Returns Core.SlotConfig

  • Gets an unspent output containing a specific NFT.

    Parameters

    • unit: AssetId

      Asset ID of the NFT.

    Returns Promise<TransactionUnspentOutput>

    A promise that resolves to the unspent output.

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

  • Posts a transaction to the blockchain.

    Parameters

    • tx: Transaction

      Transaction to post.

    Returns Promise<TransactionId>

    A promise that resolves to the transaction ID.

  • 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 slot to a unix millisecond timestamp

    Parameters

    • slot: number | bigint | Slot

      The network slot

    Returns number

    The milliseconds since midnight, Jan 1 1970

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