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

Hierarchy (view full)

Constructors

Properties

network: NetworkId
networkName: NetworkName

Methods

  • Waits for the confirmation of a given transaction.

    Parameters

    • txId: TransactionId

      The transaction id to wait for confirmation.

    • Optionaltimeout: number

      The timeout in milliseconds.

    Returns Promise<boolean>

    • A boolean indicating whether the transaction is confirmed.
  • Evaluates the transaction by calculating the exunits for each redeemer, applying them, and returning the redeemers. This makes a remote call to the provider in most cases, however may use a virtual machine in some implementations.

    Parameters

    • tx: Transaction

      The transaction to evaluate.

    • additionalUtxos: TransactionUnspentOutput[]

      The additional unspent outputs to consider.

    Returns Promise<Redeemers>

    • The redeemers with applied exunits.
  • Retrieves the unspent output for a given NFT.

    Parameters

    • unit: AssetId

      The NFT to retrieve the unspent output for.

    Returns Promise<TransactionUnspentOutput>

    • The unspent output for the NFT.
  • Retrieves the unspent outputs for a given address.

    Parameters

    • address: Address

      The address to retrieve unspent outputs for.

    Returns Promise<TransactionUnspentOutput[]>

    • The unspent outputs for the address.
  • Retrieves the unspent outputs for a given address and asset.

    Parameters

    • address: Address

      The address to retrieve unspent outputs for.

    • unit: AssetId

      The asset to retrieve unspent outputs for.

    Returns Promise<TransactionUnspentOutput[]>

    • The unspent outputs for the address and asset.
  • Posts a given transaction to the chain.

    Parameters

    • tx: Transaction

      The transaction to post to the chain.

    Returns Promise<TransactionId>

    • The id of the posted transaction.
  • Resolves the datum for a given datum hash.

    Parameters

    • datumHash: Hash32ByteBase16

      The datum hash to resolve the datum for.

    Returns Promise<PlutusData>

    • The resolved datum.
  • 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 the unspent outputs for a given set of transaction inputs.

    Parameters

    • txIns: TransactionInput[]

      The transaction inputs to resolve unspent outputs for.

    Returns Promise<TransactionUnspentOutput[]>

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