ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.82k stars 1.81k forks source link

decoding a transaction error #4325

Open sellerbtc opened 11 months ago

sellerbtc commented 11 months ago

Ethers Version

ethers": "5.7.2"

Search Terms

No response

Describe the Problem

hello please have a problem with decoding a transaction the error (Error: overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="toNumber", value="45633673574231089009591013542 007924150369919783582931797018039567302191480832", code=NUMERIC_FAULT, version=b ignumber/5.7.0) thise the original tx https://etherscan.io/tx/0x1ed5e3f9dcd118e8b235896ba1eb3ff556e39de9bfbc0b364a5bcbfca0dc8491

thnx in dvance

Code Snippet

const {ethers} = require("ethers");

data = "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000064e3be730000000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001a4f14010f12767b4640000000000000000000000000000000000000000000000000000000035705fc100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000003e34eabf5858a126cb583107e643080cee20ca64000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";

const abiCoder = new ethers.utils.AbiCoder();
decoded = abiCoder.decode(["address","uint256","uint256","address[]","bool"], data);

console.log(decoded);

Contract ABI

No response

Errors

No response

Environment

node.js (v12 or newer)

Environment (Other)

No response

ricmoo commented 11 months ago

It looks like you are passing in a tx data, which has a selector prepended to it, which is offsetting all the data you are trying to parse. Try removing the first 8 nibbles (the 3593564c).

If you use the Interface class, it does this for you. :)

sellerbtc commented 11 months ago

thnx for ur help now when i remove the 3593564c it give me another error Error: insufficient data length (length=543, count=24576, code=BUFFER_OVERRUN, v ersion=abi/5.7.0)

sellerbtc commented 11 months ago

I have solve it thank you man