Skip to content

AbiFunction Errors

AbiFunction.SelectorMismatchError

Thrown when the selector of the provided data does not match the selector of the function, or of one of its overloads.

Examples

import { AbiFunction } from 'ox'
 
const transfer = AbiFunction.from(
  'function transfer(address to, uint256 amount)'
)
 
AbiFunction.decodeData(
  transfer,
  '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000001'
)
AbiFunction.SelectorMismatchError: Selector "0x095ea7b3" does not match the expected selector "0xa9059cbb".
Function: function transfer(address to, uint256 amount)
Selector: 0xa9059cbb

Solution

Ensure that the data was encoded for the function.

import { AbiFunction } from 'ox'
 
const transfer = AbiFunction.from(
  'function transfer(address to, uint256 amount)'
)
 
AbiFunction.decodeData(
  transfer,
  '0xa9059cbb000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000001'
)

Source: src/core/AbiFunction.ts