Abi.from
Parses an arbitrary JSON ABI or Human Readable ABI into a typed Abi.Abi
.
Imports
Named
import { Abi } from 'ox'
Examples
JSON ABIs
import { Abi } from 'ox'
const abi = Abi.from([{
type: 'function',
name: 'approve',
stateMutability: 'nonpayable',
inputs: [
{
name: 'spender',
type: 'address',
},
{
name: 'amount',
type: 'uint256',
},
],
outputs: [{ type: 'bool' }],
}])
const abi: readonly [{
readonly type: "function";
readonly name: "approve";
readonly stateMutability: "nonpayable";
readonly inputs: readonly [{
readonly name: "spender";
readonly type: "address";
}, {
readonly name: "amount";
readonly type: "uint256";
}];
readonly outputs: readonly [...];
}]abi
Human Readable ABIs
import { Abi } from 'ox'
const abi = Abi.from([
'function approve(address spender, uint256 amount) returns (bool)'
])
const abi: readonly [{
readonly name: "approve";
readonly type: "function";
readonly stateMutability: "nonpayable";
readonly inputs: readonly [{
readonly type: "address";
readonly name: "spender";
}, {
readonly type: "uint256";
readonly name: "amount";
}];
readonly outputs: readonly [...];
}]abi
Definition
function from(
abi: Abi | readonly string[],
): Abi
Source: src/core/Abi.ts
Parameters
abi
- Type:
Abi | readonly string[]
The ABI to parse.
Return Type
The typed ABI.
Abi.Abi