I'd like to monitor events happening on-chain on a specific Smart Contract. I'd like to know every time a Transfer
event happens. I tried to write a code with hardhat, but no events if being logged. Here is my code:
const abi = [
"event Transfer(address indexed from, address indexed to, uint256 indexed id)"
]
const MyContract = await new hre.ethers.Contract(
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
abi,
hre.ethers.provider
)
MyContract.on("Transfer", (from, to, id) => {
console.log("Transfered:", from, to, id)
})
console.log("monitoring...")
I know that there are events occurring in the blockchain, but my code is not tracking them. What am I doing wrong?