AbiConstructor.decode
ABI-decodes the provided constructor input (inputs
).
Imports
Named
import { AbiConstructor } from 'ox'
Examples
import { AbiConstructor } from 'ox'
const constructor = AbiConstructor.from('constructor(address, uint256)')
const bytecode = '0x...'
const data = AbiConstructor.encode(constructor, {
bytecode,
args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],
})
const decoded = AbiConstructor.decode(constructor, {
bytecode,
data,
})
ABI-shorthand
You can also specify an entire ABI object as a parameter to AbiConstructor.decode
.
import { Abi, AbiConstructor } from 'ox'
const abi = Abi.from([...])
const data = AbiConstructor.encode(abi, {
bytecode: '0x...',
args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],
})
const decoded = AbiConstructor.decode(abi, {
bytecode: '0x...',
data,
})
Definition
function decode<abi, abiConstructor>(
abi: abi | Abi.Abi | readonly unknown[],
options: decode.Options,
): decode.ReturnType<abiConstructor>
Source: src/core/AbiConstructor.ts
Parameters
abi
- Type:
abi | Abi.Abi | readonly unknown[]
options
- Type:
decode.Options
Decoding options.
Return Type
The decoded constructor inputs.
decode.ReturnType<abiConstructor>