Skip to content

Ethers v6 error on listening to contracts documentation #4984

Open
@jpiabrantes

Description

@jpiabrantes

Suggestion

In this page

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationDocumentation related issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions