AbiEvent Errors
AbiEvent.ArgsMismatchError
Thrown when the provided arguments do not match the expected arguments.
Examples
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
],
})
AbiEvent.assertArgs(abiEvent, args, {
from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
value: 1n,
})
AbiEvent.ArgsMismatchError: Given arguments do not match the expected arguments. Event: event Transfer(address indexed from, address indexed to, uint256 value) from: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac to: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad value: 1 Given Arguments: from: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad to: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac value: 1
Solution
The provided arguments need to match the expected arguments.
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
],
})
AbiEvent.assertArgs(abiEvent, args, {
from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
value: 1n,
})
Source: src/AbiEvent.ts
AbiEvent.DataMismatchError
Thrown when the provided data size does not match the expected size from the non-indexed parameters.
Examples
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address to, uint256 value)',
// ↑ 32 bytes + ↑ 32 bytes = 64 bytes
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000023c34600',
// ↑ 32 bytes ❌
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
],
})
AbiEvent.DataMismatchError: Data size of 32 bytes is too small for non-indexed event parameters. Non-indexed Parameters: (address to, uint256 value) Data: 0x0000000000000000000000000000000000000000000000000000000023c34600 (32 bytes)
Solution
Ensure that the data size matches the expected size.
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address to, uint256 value)',
// ↑ 32 bytes + ↑ 32 bytes = 64 bytes
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000023c34600',
// ↑ 64 bytes ✅
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
],
})
Source: src/AbiEvent.ts
AbiEvent.FilterTypeNotSupportedError
Thrown when the provided filter type is not supported.
Examples
import { AbiEvent } from 'ox'
const transfer = AbiEvent.from('event Transfer((string) indexed a, string b)')
AbiEvent.encode(transfer, {
a: ['hello'],
})
AbiEvent.FilterTypeNotSupportedError: Filter type "tuple" is not supported.
Solution
Provide a valid event input type.
import { AbiEvent } from 'ox'
const transfer = AbiEvent.from('event Transfer((string) indexed a, string b)')
const transfer = AbiEvent.from('event Transfer(string indexed a, string b)')
Source: src/AbiEvent.ts
AbiEvent.InputNotFoundError
Thrown when no argument was found on the event signature.
Examples
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
],
})
AbiEvent.assertArgs(abiEvent, args, {
a: 'b',
from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
value: 1n,
})
AbiEvent.InputNotFoundError: Parameter "a" not found on `event Transfer(address indexed from, address indexed to, uint256 value)`.
Solution
Ensure the arguments match the event signature.
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
],
})
AbiEvent.assertArgs(abiEvent, args, {
a: 'b',
from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
value: 1n,
})
Source: src/AbiEvent.ts
AbiEvent.SelectorTopicMismatchError
Thrown when the provided selector does not match the expected selector.
Examples
import { AbiEvent } from 'ox'
const transfer = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, bool sender)',
)
AbiEvent.decode(transfer, {
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
],
})
AbiEvent.SelectorTopicMismatchError: topics[0]="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" does not match the expected topics[0]="0x3da3cd3cf420c78f8981e7afeefa0eab1f0de0eb56e78ad9ba918ed01c0b402f". Event: event Transfer(address indexed from, address indexed to, bool sender) Selector: 0x3da3cd3cf420c78f8981e7afeefa0eab1f0de0eb56e78ad9ba918ed01c0b402f
Solution
Ensure that the provided selector matches the selector of the event signature.
import { AbiEvent } from 'ox'
const transfer = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, bool sender)',
)
AbiEvent.decode(transfer, {
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x3da3cd3cf420c78f8981e7afeefa0eab1f0de0eb56e78ad9ba918ed01c0b402f',
'0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
],
})
Source: src/AbiEvent.ts
AbiEvent.TopicsMismatchError
Thrown when the provided topics do not match the expected number of topics.
Examples
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
],
})
AbiEvent.TopicsMismatchError: Expected a topic for indexed event parameter "to" for "event Transfer(address indexed from, address indexed to, uint256 value)".
Solution
Ensure that the topics match the expected number of topics.
import { AbiEvent } from 'ox'
const abiEvent = AbiEvent.from(
'event Transfer(address indexed from, address indexed to, uint256 value)',
)
const args = AbiEvent.decode(abiEvent, {
data: '0x0000000000000000000000000000000000000000000000000000000000000001',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
],
})
Source: src/AbiEvent.ts