AbiParameters Errors
AbiParameters.ArrayLengthMismatchError
The length of the array value does not match the length specified in the corresponding ABI parameter.
Example
AbiParameters.encode(AbiParameters.from('uint256[3]'), [[69n, 420n]])
// ↑ expected: 3 ↑ ❌ length: 2
AbiParameters.ArrayLengthMismatchError: ABI encoding array length mismatch for type `uint256[3]`. Expected: `3`. Given: `2`.
Solution
Pass an array of the correct length.
AbiParameters.encode(AbiParameters.from(['uint256[3]']), [[69n, 420n, 69n]])
// ↑ ✅ length: 3
Source: src/AbiParameters.ts
AbiParameters.BytesSizeMismatchError
The size of the bytes value does not match the size specified in the corresponding ABI parameter.
Example
AbiParameters.encode(AbiParameters.from('bytes8'), [['0xdeadbeefdeadbeefdeadbeef']])
// ↑ expected: 8 bytes ↑ ❌ size: 12 bytes
BytesSizeMismatchError: Size of bytes "0xdeadbeefdeadbeefdeadbeef" (bytes12) does not match expected size (bytes8).
Solution
Pass a bytes value of the correct size.
AbiParameters.encode(AbiParameters.from(['bytes8']), ['0xdeadbeefdeadbeef'])
// ↑ ✅ size: 8 bytes
Source: src/AbiParameters.ts
AbiParameters.DataSizeTooSmallError
Throws when the data size is too small for the given parameters.
Examples
import { AbiParameters } from 'ox'
AbiParameters.decode([{ type: 'uint256' }], '0x010f')
// ↑ ❌ 2 bytes
AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters. Params: (uint256) Data: 0x010f (2 bytes)
Solution
Pass a valid data size.
import { AbiParameters } from 'ox'
AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')
// ↑ ✅ 32 bytes
Source: src/AbiParameters.ts
AbiParameters.InvalidArrayError
The value provided is not a valid array as specified in the corresponding ABI parameter.
Example
AbiParameters.encode(AbiParameters.from(['uint256[3]']), [69])
Solution
Pass an array value.
Source: src/AbiParameters.ts
AbiParameters.InvalidTypeError
Throws when the ABI parameter type is invalid.
Examples
import { AbiParameters } from 'ox'
AbiParameters.decode([{ type: 'lol' }], '0x00000000000000000000000000000000000000000000000000000000000010f')
// ↑ ❌ invalid type
AbiParameters.InvalidTypeError: Type `lol` is not a valid ABI Type.
Source: src/AbiParameters.ts
AbiParameters.LengthMismatchError
The length of the values to encode does not match the length of the ABI parameters.
Example
AbiParameters.encode(AbiParameters.from(['string', 'uint256']), ['hello'])
LengthMismatchError: ABI encoding params/values length mismatch. Expected length (params): 2 Given length (values): 1
Solution
Pass the correct number of values to encode.
Solution
Pass a valid ABI type.
Source: src/AbiParameters.ts
AbiParameters.ZeroDataError
Throws when zero data is provided, but data is expected.
Examples
import { AbiParameters } from 'ox'
AbiParameters.decode([{ type: 'uint256' }], '0x')
// ↑ ❌ zero data
AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters. Params: (uint256) Data: 0x010f (2 bytes)
Solution
Pass valid data.
import { AbiParameters } from 'ox'
AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')
// ↑ ✅ 32 bytes
Source: src/AbiParameters.ts