Skip to content

Error on Events triggering #3767

@marsniper27

Description

@marsniper27

Ethers Version

6.02

Search Terms

events, event

Describe the Problem

While creating event listeners upon receipt of event an error occurs. Simplified example provided.
This is occurring for multiple contracts and events. Switching to v5.7.2 the events work fine.

Code Snippet

const { ethers } =  require(`ethers`);

const newEthersClient = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/polygon/486f6d938d85e35aeacf83a59afd95c4fab739093c8f919adb258799d81d51bf');

abi = [
    "event Transfer(address indexed from, address indexed to, uint amount)"
  ]
  
  contract = new ethers.Contract("0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", abi, newEthersClient)
  
  // Begin listening for any Transfer event
  contract.on("Transfer", (from, to, _amount, event) => {
    const amount = ethers.formatEther(_amount, 18)
    console.log(`${ from } => ${ to }: ${ amount }`);
  
    // The `event.log` has the entire EventLog
  
    // Optionally, convenience method to stop listening
    event.removeListener();
  });

Contract ABI

[
    "event Transfer(address indexed from, address indexed to, uint amount)"
  ]

Errors

Uncaught TypeError TypeError: unknown ProviderEvent (argument="event", value="{\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\"],\"address\":[\"0x8f3cf7ad23cd3cadbd9735aff958023239c6a063\"]}", code=INVALID_ARGUMENT, version=6.0.2)

Environment

node.js (v12 or newer)

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions