ScriptTransactionRequest provides functionalities for creating a transaction request that uses a script.

Hierarchy (view full)

Constructors

  • Constructor for ScriptTransactionRequest.

    Parameters

    • scriptTransactionRequestLike: ScriptTransactionRequestLike = {}

      The initial values for the instance.

    Returns ScriptTransactionRequest

Properties

expiration?: number

The block number after which the transaction is no longer valid.

gasLimit: BN

Gas limit for transaction

List of inputs

maturity?: number

Block until which tx cannot be included

maxFee: BN

The maximum fee payable by this transaction using BASE_ASSET.

outputs: TransactionRequestOutput[] = []

List of outputs

script: Uint8Array<ArrayBufferLike>

Script to execute

scriptData: Uint8Array<ArrayBufferLike>

Script input data (parameters)

tip?: BN

Gas price for transaction

type: Script = ...

Type of the transaction

witnessLimit?: BN

The maximum amount of witness data allowed for the transaction

witnesses: BytesLike[] = []

List of witnesses

Methods

  • Adds a change output to the transaction.

    Parameters

    Returns void

  • Adds a single coin input to the transaction and a change output for the related assetId, if one it was not added yet.

    Parameters

    • coin: Coin

      Coin resource.

    Returns void

  • Adds a contract input and output to the transaction request.

    Parameters

    Returns ScriptTransactionRequest

    The current instance of the ScriptTransactionRequest.

  • Adds a single message input to the transaction and a change output for the asset against the message

    Parameters

    Returns void

  • Adds variable outputs to the transaction request.

    Parameters

    • numberOfVariables: number = 1

      The number of variables to add.

    Returns number

    The new length of the outputs array.

  • Returns number

  • Calculates the maximum gas for the transaction.

    Parameters

    • chainInfo: ChainInfo

      The chain information.

    • minGas: BN

      The minimum gas.

    Returns BN

    the maximum gas.

  • Helper function to estimate and fund the transaction request with a specified account.

    Parameters

    Returns Promise<ScriptTransactionRequest>

    The current instance of the ScriptTransactionRequest funded.

  • Funds the transaction with fake UTXOs for each assetId and amount in the quantities array.

    Parameters

    • quantities: CoinQuantity[]

      CoinQuantity Array.

    • baseAssetId: string

      The base asset to fund the transaction.

    • OptionalresourcesOwner: Address

    Returns ScriptTransactionRequest

    • This method is deprecated and will be removed in future versions. Please use Account.generateFakeResources along with this.addResources instead.
  • Method to obtain the base transaction details.

    Returns ToBaseTransactionResponse

    The base transaction details.

  • Gets the Transaction Request by hashing the transaction.

    Parameters

    • chainId: number

      The chain ID.

    Returns string

    • A hash of the transaction, which is the transaction ID.
  • Parameters

    • index: number

    Returns void

  • Sets the data for the transaction request.

    Parameters

    Returns ScriptTransactionRequest

    The current instance of the ScriptTransactionRequest.

  • Set the script and its data.

    Type Parameters

    • T

    Parameters

    • script: AbstractScriptRequest<T>

      The abstract script request.

    • data: T

      The script data.

    Returns void

  • Return the minimum amount in native coins required to create a transaction.

    Returns any

    The transaction as a JSON object.

  • Converts the transaction request to a byte array.

    Returns Uint8Array<ArrayBufferLike>

    The transaction bytes.

  • Updates an existing witness without any side effects.

    Parameters

    • index: number

      The index of the witness to update.

    • witness: BytesLike

      The new witness.

    Returns void

    If the witness does not exist.

  • Updates the witness for a given owner and signature.

    Parameters

    • address: AddressInput

      The address to get the coin input witness index for.

    • signature: BytesLike

      The signature to update the witness with.

    Returns void