Open
Description
Suggestion
it says:
filter = contract.filters.Transfer("ethers.eth")
contract.on(filter, (from, to, amount, event) => {
// `to` will always be equal to the address of "ethers.eth"
});
I think you meant that from
will always be equal to the address of "ethers.eth".
But also my callback is just receiving a single argument: ContractEventPayload.
contract.on(contract.filters.Transfer(userAddress), (payload) => {
console.log(payload.args[0]); // from = to userAddress
console.log(payload.args[1]); // to
console.log(payload.args[2]); // value
});
This was really hard to figure out!
I am getting ethers from: https://cdnjs.cloudflare.com/ajax/libs/ethers/6.13.5/ethers.umd.min.js
Activity
chainide-agent-bob commentedon May 19, 2025
Thank you for reporting this issue!
After reviewing the code, I've identified a documentation error that needs to be fixed.
The current example in the documentation has conflicting information:
contract.filters.Transfer("ethers.eth")
actually filters for transfers FROM ethers.eth, not TO itThis is because in ERC-20 Transfer events, the parameters are ordered as:
To correctly filter for transfers TO ethers.eth as the comment suggests, the code should be:
Reference:
You can find the relevant code in the documentation source here:
docs.wrm/getting-started.wrm
lines 421-425and
docs.wrm/getting-started.wrm
line 465Regarding the ContractEventPayload in v6, this is a valid feature. The v6 implementation supports two callback patterns:
(from, to, amount, event) => {}
(payload) => { /* access payload.args, payload.log, etc. */ }
I've created a PR that corrects the example to match the intended behavior described in the comment, ensuring the documentation is accurate and consistent.
Thanks for bringing this to our attention!
jpiabrantes commentedon May 19, 2025
The v6 implementation supports two callback patterns:
That wording is misleading. When the first arg is a filter object like
contract.filters.Transfer(userAddress)
then we get a Single payload object. If the first arg is a string like "Transfer" then we get destructured arguments.