简体   繁体   中英

How to listen to a *unnamed* Event?

I am trying to listen for this event, but it does not have an actual name. Is there a way to Listen for event 0x0511a506?

You can use the generic subscribe("logs") handler ( docs ) and filter by the contract address and event signature ( topics[0] ).

Mind that the 0x0511a506 mentioned in your question is a selector of the parent function that was invoked while the event was emitted, but you're really looking for the event signature - 0x598cd562... in your case.

web3.eth.subscribe("logs", {
    address: "contractAddress",
    topics: [
        "0x598cd562..."
    ]
}, (err, data) => {
    console.log(data);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM