Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethereum Solidity ABI Decoder Error: "value exceeds width (20 bits)" #4446

Closed
mohamed0807 opened this issue Nov 1, 2023 · 2 comments
Closed
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@mohamed0807
Copy link

Ethers Version

6.8. 0

Search Terms

No response

Describe the Problem

'm working on a project involving Ethereum contract interactions and am facing an issue with decoding data from a transaction. I have this hexadecimal data

Code Snippet

let data = "0xa9059cbb00000000000000000000004161c0b5a78975cf799b054e27d2f3e8be1fc893bf00000000000000000000000000000000000000000000000000000000001e8480"
const decodedValues = abiCoder.decode(types.map(ParamType.from), data);

Contract ABI

No response

Errors

DECODED Result(2) [
  value exceeds width (20 bits) (operation="toBeHex", fault="overflow", value=76450787359836037641860180984291677772229208647895581217323133373013917165758, code=NUMERIC_FAULT, version=6.8.0)
      at makeError (/path/to/node_modules/ethers/lib.commonjs/utils/errors.js:126:21)
      at assert (/path/to/node_modules/ethers/lib.commonjs/utils/errors.js:149:15)
      at toBeHex (/path/to/node_modules/ethers/lib.commonjs/utils/maths.js:178:32)
      at AddressCoder.decode (/path/to/node_modules/ethers/lib.commonjs/abi/coders/address.js:29:66)
      at /path/to/node_modules/ethers/lib.commonjs/abi/coders/array.js:86:31
      at Array.forEach (<anonymous>)
      at unpack (/path/to/node_modules/ethers/lib.commonjs/abi/coders/array.js:65:12)
      at TupleCoder.decode (/path/to/node_modules/ethers/lib.commonjs/abi/coders/tuple.js:63:38)
      at AbiCoder.decode (/path/to/node_modules/ethers/lib.commonjs/abi/abi-coder.js:182:22)
      at decode (/path/to/trx.js:99:34) {
    code: 'NUMERIC_FAULT',
    operation: 'toBeHex',
    fault: 'overflow',
    value: 76450787359836037641860180984291677772229208647895581217323133373013917165758n,
    shortMessage: 'value exceeds width (20 bits)',
    baseType: 'address',
    type: 'address'
  },
  14376087425099726544138662156556021388263377962693529595350340835567210594304n
]

Environment

No response

Environment (Other)

No response

@mohamed0807 mohamed0807 added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Nov 1, 2023
@ricmoo
Copy link
Member

ricmoo commented Nov 1, 2023

This is a duplicate of #4427.

That means your encoded data is incorrect, which usually means the contract likely uses assembly and producing malformed data. Which contract is this, and is it related to the contract in the other issue?

@ricmoo
Copy link
Member

ricmoo commented Nov 1, 2023

The first part of this (the incorrect error message) has been fixed in v6.8.1. Please see the other issue to track further discussions on how to handle invalid input where the only problem is dirty data and stray bytes.

@ricmoo ricmoo closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants