-
Ethers Version5.7.1 Search TermsNo response Describe the ProblemI have unexpected error when try to parse log which actually is Code Snippetconst { ethers } = require("ethers");
const logJson = `{
"transactionIndex": 12,
"blockNumber": 7918462,
"transactionHash": "0x8553e3c03549563cb47ca1c30fcab2a6bea929b19622d6163fdb66b03b53920e",
"address": "0x3996002cea99bc220f992e4c868702a5ba60bd26",
"topics": [
"0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb",
"0x0000000000000000000000001c08d194d547a56aa6a20f2c90818b954cda2054",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000e2fbb99ddb441a822b047c518d7d697eea8d5274"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002",
"logIndex": 9,
"blockHash": "0xd2fc8b49be3587306e7e2789b29376dcab6ddd0857949ce3396dcf49134f17ae",
"timestamp": 1667952300
}`;
const log = JSON.parse(logJson);
const iface = new ethers.utils.Interface(["event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)"]);
const parsedLog = iface.parseLog({ topics: log.topics, data: log.data }); Contract ABI["event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)"] ErrorsError: data out-of-bounds (length=0, offset=32, code=BUFFER_OVERRUN, version=abi/5.7.0)
at Logger.makeError (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/logger/lib/index.js:247:20)
at Reader._peekBytes (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:150:24)
at Reader.readBytes (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:162:26)
at Reader.readValue (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:168:48)
at ArrayCoder.decode (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/array.js:214:28)
at /Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/array.js:94:31
at Array.forEach (<anonymous>)
at unpack (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/array.js:88:12)
at TupleCoder.decode (/Users/alexeybreez/Projects/mozverse/nft-supernode-api/node_modules/@ethersproject/abi/lib/coders/tuple.js:74:60) {
reason: 'data out-of-bounds',
code: 'BUFFER_OVERRUN',
length: 0,
offset: 32
} Environmentnode.js (v12 or newer) Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Just by inspection, I can tell the log data is not sufficient for two dynamic-length arrays; each dynamic-length array (the non-indexed parameters) requires 2 words (a pointer, and a length) for a total of 4 words. It looks to be about 2 words. You should check the contract; maybe they are using asm to emit the log and not computing it correctly. The two words look to encode the values 8 and 2. |
Beta Was this translation helpful? Give feedback.
Just by inspection, I can tell the log data is not sufficient for two dynamic-length arrays; each dynamic-length array (the non-indexed parameters) requires 2 words (a pointer, and a length) for a total of 4 words. It looks to be about 2 words.
You should check the contract; maybe they are using asm to emit the log and not computing it correctly. The two words look to encode the values 8 and 2.