Unable to decode bytes with error data out-of-bounds
#3907
-
Ethers Version6.1.0 Search Termsout-of-bounds, decode, bytes Describe the ProblemI am trying to decode a log from this transaction https://etherscan.io/tx/0x0bc594ca26e416407d37055e3b171d5ed60925477e78f644b033a251e5a84731#eventlog, on the log index 68. However, when I tried to decode it throws me an error as shown: Not sure what I am missing Code Snippetconst parameters = ['address','address','uint256','bytes','bytes'];
const data = '0x00000000000000000000000097be09f2523b39b835da9ea3857cfa1d3c660cbb00000000000000000000000097be09f2523b39b835da9ea3857cfa1d3c660cbb000000000000000000000000000000000000000000000000840e6997d866bceb000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
const defaultAbiCoder = new ethers.AbiCoder();
const values = defaultAbiCoder.decode(parameters, data);
console.log(values); Contract ABINo response Errorsdata out-of-bounds (buffer=0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, length=96, offset=160, code=BUFFER_OVERRUN, version=6.1.0)
at makeError /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/utils/errors.ts:660
at assert /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/utils/errors.ts:680
at Reader.#peekBytes /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/abstract-coder.ts:419
at Reader.readBytes /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/abstract-coder.ts:436
at BytesCoder.decode /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/bytes.ts:28
at BytesCoder.decode /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/bytes.ts:41
at /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/array.ts:93
at unpack /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/array.ts:86
at TupleCoder.decode /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/coders/tuple.ts:66
at AbiCoder.decode /project/node_modules/.pnpm/[email protected]/node_modules/ethers/src.ts/abi/abi-coder.ts:208 Environmentnode.js (v12 or newer) Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In a Log, the data only encoded the non-indexed parameters, so if you are going to manually decode the data, you have to remove the indexed parameters from your list of types. If you use the Interface directly, this is taken care of for you. :) |
Beta Was this translation helpful? Give feedback.
In a Log, the data only encoded the non-indexed parameters, so if you are going to manually decode the data, you have to remove the indexed parameters from your list of types.
If you use the Interface directly, this is taken care of for you. :)