Subscribe.on fires past events
See original GitHub issueEthers Version
5.6.5
Search Terms
subscribe new events filter
Describe the Problem
Hi,
when I am subscribing to a contract’s events I am also seeing past events even the filter fromBlock: 'latest'
is set.
Am I doing something incorrectly?
import { useProvider } from "wagmi";
const provider = useProvider();
const contract = await new ethers.Contract(
address,
abi,
provider
);
const listener: Listener = (id: BigNumber, user: string) =>
console.dir("id", id.toString(), "user", user)
contract.on(
// "CancelOrderEvent",
{
topics: [utils.id("CancelOrderEvent(uint256,address)")],
fromBlock: "latest",
},
listener
)
I should mention, I am using wagmi however, I don’t think that changes the way ethers works as I just work with the ethers.Contract.
Help appreciated, cheers 🙏🏼
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
Ethereum (mainnet/ropsten/rinkeby/goerli), node.js (v12 or newer), Hardhat, Ganache
Environment (Other)
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Ready For Wildfire App
Use the CAL FIRE app to create a personalized wildfire readiness plan and learn about active incident information to find "fires near me."...
Read more >Subscribe fires twice when I revisit a page - angular
As your old subscriptions will keep listening to old Subjects. ... This worked perfectly and prevents triggering multiple subscribe events.
Read more >web3.eth.subscribe — web3.js 1.0.0 documentation
The web3.eth.subscribe function lets you subscribe to specific events in the ... "error" returns Object : Fires when an error in the subscription...
Read more >Stats & Events - CAL FIRE - CA.gov
Stats and Events. ... Subscribe To Receive News Releases and Incident Updates: Click to subscribe for news ... Historical Wildfire Activity Statistics ...
Read more >Subscribe to Platform Events Unit | Salesforce Trailhead
Now that you've seen how to publish platform events, how do you subscribe to them to be ... Publishing the event causes the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks! I have found the bug.
Yes, this was introduced with the fix for networks which have non-consistent event indexing (e.g. Polygon and BSC).
This fix will go out in v5.7.0.
I’m getting previous events fired with
contract.on
using ganache testnet. Can I assume this is an artifact of ganache?