Skip to content

AbiConstructor.fromAbi

Extracts an AbiConstructor.AbiConstructor from an Abi.Abi given a name and optional arguments.

Imports

Named
import { AbiConstructor } from 'ox'

Examples

Extracting by Name

ABI Events can be extracted by their name using the name option:

import { Abi, AbiConstructor } from 'ox'
 
const abi = Abi.from([
  'constructor(address owner)',
  'function foo()',
  'event Transfer(address owner, address to, uint256 tokenId)',
  'function bar(string a) returns (uint256 x)',
])
 
const 
const item: { readonly type: "constructor"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "owner"; }]; }
item
= AbiConstructor.fromAbi(abi)

Definition

function fromAbi(
  abi: Abi.Abi | readonly unknown[],
): AbiConstructor

Source: src/AbiConstructor.ts

Parameters

abi

  • Type: Abi.Abi | readonly unknown[]

Return Type

The ABI constructor.

AbiConstructor.AbiConstructor

Error Type

AbiConstructor.fromAbi.ErrorType