I am working on simple smart contract interaction integration. And trying to make client's browser catch events.
Contract looks like
contract MyContract is Ownable {
....
event Created(address _creator, unit256 _value);
function create() public payable returns (uint256) {
....
emit Created(msg.sender, msg.value);
}
On the browser's side I am doing following:
const provider = new ethers.BrowserProvider(window.ethereum);
this.provider.on("block", (blockNumber) => {
console.log("event Block: ", blockNumber);
});
this.provider.on("pending", (pendingTransaction) => {
console.log("event Block: ", pendingTransaction);
});
and expecting to see something once Hardhat's network make new block (for instance - I calling contract's method from RemixIDE). But nothing.
Any idea what I should fix?
Using Ethers.js v6 as wrapper for ethereum provider.