Skip to content

AbiFunction.encodeResult

ABI-encodes a function's result (outputs).

Imports

Named
import { AbiFunction } from 'ox'

Examples

import { AbiFunction } from 'ox'
 
const totalSupply = AbiFunction.from('function totalSupply() returns (uint256)')
const output = AbiFunction.decodeResult(totalSupply, '0x000000000000000000000000000000000000000000000000000000000000002a')
// 42n
 
const data = AbiFunction.encodeResult(totalSupply, 42n)
'0x000000000000000000000000000000000000000000000000000000000000002a'

Definition

function encodeResult<abiFunction, as>(
  abiFunction: abiFunction | AbiFunction,
  output: encodeResult.Output<abiFunction, as>,
  options?: encodeResult.Options<as>,
): Hex.Hex

Source: src/core/AbiFunction.ts

Parameters

abiFunction

  • Type: abiFunction | AbiFunction

The ABI item to encode the function output for.

output

  • Type: encodeResult.Output<abiFunction, as>

The function output to encode.

options

  • Type: encodeResult.Options<as>
  • Optional

Encoding options.

options.as

  • Type: "Array" | "Object" | as
  • Optional

Return Type

The encoded function output.

Hex.Hex