Created
January 30, 2023 22:05
-
-
Save kalloc/bcde7e56aae6a41531e3159b583f41f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3'); | |
const web3 = new Web3(new Web3.providers.WebsocketProvider(process.env.ENDPOINT)); | |
const transferSignature = Web3.utils.keccak256("Transfer(address,address,uint256)"); | |
// Listen for Transfer events from all contracts | |
web3.eth.subscribe('logs', { | |
topics: [transferSignature] | |
}, (error, event) => { | |
if (error) { | |
console.error(error); | |
} else { | |
console.log(`Transfer event occurred in contract ${event.address} with parameters:`, event.data); | |
} | |
}) | |
.on('data', log => { | |
console.log(`Transfer event data:`, log); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment