Format of ABI when listening to an event? #4387
marsrobertson
started this conversation in
General
Replies: 1 comment
-
Bump... I'm revisiting this area of code and it stil makes me wonder? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When initialising contract, I use the following syntax:
const BaseXContract = new ethers.Contract(ADDRESS, ABI, provider);
And it is working fine, I can read data from the contract.
BUT the listening to the event, it is not working:
BaseXContract.on("ItemAdded", async (eventData) => { ...
So I've asked ChatGPT to help me...
AI generated snippet to try things out...
In this snippet I've noticed the syntax:
"event Transfer(address indexed from, address indexed to, uint256 value)"
So I went to my code and changed how I instantiate the contract to follow the working example:
Now it works
I don't want to instantiate contract twice.
I would like to keep the way how I instantiate the contract using the following ABI syntax:

But then it will not listen to events. Any ideas?
Using
node.js
and ethersv5.6
Beta Was this translation helpful? Give feedback.
All reactions