Class ABIFunction<TAbi, TFunctionName>

Represents a function call in the Function ABI.

Type Parameters

  • TAbi extends ViemABI = ViemABI
  • TFunctionName extends ContractFunctionName<TAbi> = ContractFunctionName<TAbi>

Hierarchy (view full)

Constructors

Properties

signature: AbiEvent | AbiFunction
stringSignature: string

Accessors

  • get bi(): bigint
  • Throws an exception because the ABI cannot be represented as a big integer.

    Returns bigint

    The BigInt representation of the ABI.

    The ABI cannot be represented as a bigint. VeChainDataModel#bi

    The conversion to BigInt is not supported for an ABI.

  • get bytes(): Uint8Array
  • Encodes the values according to the specified ABI types when creating the ABI instance.

    Returns Uint8Array

    The ABI-encoded bytes representing the given values.

  • get n(): number
  • Throws an exception because the ABI cannot be represented as a number.

    Returns number

    The number representation of the ABI.

    The mnemonic cannot be represented as a number. VeChainDataModel#n

    The conversion to number is not supported for an ABI.

Methods

  • Decodes a function output returning an array of values.

    Parameters

    • data: Hex

      The data to be decoded

    Returns unknown[]

    The decoded data as array of values

  • Decodes the output data from a transaction based on ABI (Application Binary Interface) specifications. This method attempts to decode the given hex-like data into a readable format using the contract's interface.

    Parameters

    • data: Hex

      The data to be decoded, typically representing the output of a contract function call.

    Returns DecodeFunctionResultReturnType<TAbi, TFunctionName>

    An object containing the decoded data.

      const decoded = abiFunctionInstance.decodeResult(rawTransactionOutput);
    console.log('Decoded Output:', decoded);
  • Returns a string representation of a JSON object or a string.

    Parameters

    • formatType: "string" | "json" = 'string'

      Either JSON or String

    Returns string

    The string representation of the ABI item.

  • Checks if the current ABI object is equal to the given ABI object.

    Parameters

    • that: ABI

      The ABI object to compare with.

    Returns boolean

    True if the objects are equal, false otherwise. VeChainDataModel#isEqual

    The comparison is done by comparing the types and values of the ABI instances.

  • Recursively parses an object and collects the values of each attribute into an array, with nested arrays for nested objects.

    Parameters

    • obj: object

      The object to parse.

    Returns unknown[]

    An array of values from the object, with nested arrays for nested objects.

  • Instantiates an ABI object from the given types and values.

    Parameters

    • types: string | AbiParameter[]

      ABI parameters representing the types of the values.

    • values: unknown[]

      ABI values.

    Returns ABI

    The ABI object with the given types and values.

  • Decodes the ABI values from the given ABI types and encoded data.

    Parameters

    • types: string | AbiParameter[]

      The list of ABI types representing the types of the values to decode.

    • dataEncoded: string | Uint8Array

      The encoded data to decode.

    Returns ABI

    An ABI instance with the decoded values.