0

I had asked this question but I omitted some info as I (wrongly) assumed that the omitted info was not part of my problem.

When you emit an event like so:

event ChildCreated(address indexed creator, address child, uint length);

and decode it like so in ethers js

return ethers.utils.defaultAbiCoder.decode(["address","address","uint256"], log.data);

You get an error:

Exception: null: value out of range (argument="value", value=20, code=INVALID_ARGUMENT, version=bytes/5.4.0

Why?

1 Answer 1

1

Thanks to this github thread I have been able to find a solution.

The solution lies in that indexed parameters are not included in the connection.data, but in the connection.topics.

And from the same github thread they have given code to decode events with indexed parameters.

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));
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.