Represents an ABI (Application Binary Interface).

Type Parameters

  • TAbi extends ViemABI

Hierarchy (view full)

Constructors

Properties

abi: TAbi

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

  • Compares the current ABI instance with another ABI instance.

    Parameters

    • that: ABI

      The ABI to compare with.

    Returns number

    A non-zero number if the current ABI is different to the other ABI or zero if they are equal. VeChainDataModel#compareTo

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

  • Decodes event log data based on the provided event name, and data/topics to decode.

    Type Parameters

    • TEventName extends string

    Parameters

    • eventName: string | TEventName

      The name of the event to be decoded.

    • eventToDecode: ABIEventData

      An object containing the data and topics to be decoded.

    Returns DecodeEventLogReturnType<TAbi, TEventName>

    The decoded data of the event log.

  • Decodes the output from a contract function using the specified ABI and function name. It takes the encoded function output and attempts to decode it according to the ABI definition.

    Type Parameters

    • TFunctionName extends string

    Parameters

    • functionName: string | TFunctionName

      The name of the function in the contract to decode the output for.

    • encodedFunctionOutput: Hex

      The encoded output data from the contract function.

    Returns DecodeFunctionResultReturnType<TAbi, TFunctionName>

    • The decoded output, which provides a user-friendly way to interact with the decoded data.
    // Example of decoding output for a function called "getValue":
    const decodedOutput = decodeFunctionOutput('getValue', encodedValue);
  • Encodes event log data based on the provided event name, and data to encode.

    Type Parameters

    • TEventName extends string

    Parameters

    • eventName: string | TEventName

      The name of the event to be encoded.

    • eventArgs: unknown[]

      An array of data to be encoded in the event log.

    Returns ABIEventData

    An object containing the encoded data and topics.

  • Encode function data that can be used to send a transaction.

    Type Parameters

    • TFunctionName extends string

    Parameters

    • functionName: string | TFunctionName

      The name of the function defined in the ABI.

    • OptionalfunctionData: unknown[]

      The data to pass to the function.

    Returns Hex

    The encoded data in hexadecimal that can be used to send a transaction.

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

  • Decodes a VeChain log based on the ABI definition.

    This method takes raw data and topics from a VeChain log and attempts to decode them using the contract's ABI definition. If the decoding is successful, it returns a log object representing the decoded information. If the decoding fails, it throws a custom error with detailed information.

    Type Parameters

    • TEventName extends string

    Parameters

    • data: Hex

      The hexadecimal string of the data field in the log.

    • topics: Hex[]

      An array of hexadecimal strings representing the topics of the log.

    Returns DecodeEventLogReturnType<TAbi, TEventName>

    • A log object representing the decoded log or null if decoding fails.
  • Parses the log data and topics into an array of values.

    Parameters

    • data: Hex

      The hexadecimal string of the data field in the log.

    • topics: Hex[]

      An array of hexadecimal strings representing the topics of the log.

    Returns unknown[]

    • An array of values of the decoded log data.
  • 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.