AbiCoder
The AbiCoder is a low-level class responsible for encoding JavaScript values into binary data and decoding binary data into JavaScript values.
Methods
decode()
decode(
types,
data,
loose?): Result
Decode the ABI data as the types into values.
If loose decoding is enabled, then strict padding is not enforced. Some older versions of Solidity incorrectly
padded event data emitted from external
functions.
Parameters
Parameter | Type | Description |
---|---|---|
types | readonly (string | ParamType )[] | Array of parameter types. |
data | BytesLike | The ABI data to decode. |
loose ? | boolean | Enable loose decoding. Default is false |
Returns
The decoded values.
Source
encode()
encode(types, values): string
Encode the values as the specified types into ABI data.
Parameters
Parameter | Type | Description |
---|---|---|
types | readonly (string | ParamType )[] | Array of parameter types. |
values | readonly any [] | Array of values to encode. |
Returns
string
The encoded data in hexadecimal format.
Source
getDefaultValue()
getDefaultValue(types): Result
Get the default values for the given types. For example, a uint
is by default 0
and bool
is by default
false
.
Parameters
Parameter | Type | Description |
---|---|---|
types | readonly (string | ParamType )[] | Array of parameter types to get default values for. |
Returns
The default values corresponding to the given types.
Source
defaultAbiCoder()
static defaultAbiCoder(): AbiCoder
Returns the shared singleton instance of a default AbiCoder.
On the first call, the instance is created internally.
Returns
The default ABI coder instance.
Source
getBuiltinCallException()
static getBuiltinCallException(
action,
tx,
data): CallExceptionError
Returns a quais-compatible CallExceptionError for the given result data.
Parameters
Parameter | Type | Description |
---|---|---|
action | CallExceptionAction | The action that triggered the exception. |
tx | object | The transaction information. |
tx.data ? | string | - |
tx.from ? | null | string | - |
tx.to ? | null | string | - |
data | null | BytesLike | The data associated with the call exception. |
Returns
The corresponding call exception error.
Source
Was this page helpful?