I fetched logs via provider.getLogs. Now I try to decode the data with this:
ethers.utils.defaultAbiCoder.decode(
[ 'string','string','bytes32','string','address' ],
connection.data
)
But I get
Error: overflow (operation="setValue", fault="overflow", details="Number can only safely store up to 53 bits", version=4.0.23)
The data comes from this event:
event newConnect (
string indexed hashedName,
string name,
bytes32 connectId,
string encrypted,
address owner
);
Keep in mind that that indexed parameters are not included in the connection.data, but in the connection.topics. You probably want something like:
ethers.utils.defaultAbiCoder.decode(
[ 'string', 'bytes32', 'string', 'address' ],
connection.data
);
without the first 'string'. You can also use the Interface API to help:
let abi = [
"event newConnect (string indexed hashedName, string name, bytes32 connectId, string encrypted, address owner)"
];
let iface = new ethers.utils.Interface(abi)
getLogs.then((logs) => {
logs.forEach((log) => {
console.log(iface.parseLog(log));
});
});
That is just typed off the top of my head, so there may be typos, but that should get you started. :)
No typos at all and both solutions work like a charm. Thank you very much!
I have spent the last two days troubleshooting, this thread has given me the solution. I am using etherjs, I wish they had documented well that indexed parameters are not included in the connection.data, but in the connection.topics.
Most helpful comment
Keep in mind that that
indexedparameters are not included in theconnection.data, but in theconnection.topics. You probably want something like:without the first 'string'. You can also use the Interface API to help:
That is just typed off the top of my head, so there may be typos, but that should get you started. :)