I don't understand how to get events with ethers v6, I tried in this way:
if (window.ethereum == null) {
console.log("Metamask is not installed; using read-only defaults");
const provider = ethers.getDefaultProvider();
// ...
} else {
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const abi = BiteIDNFT_abi;
const contractNFT = new ethers.Contract("contractaddress", abi, signer);
await contractNFT.safeMint("contractaddress", "ipfs://test");
contractNFT.on("*", (from, to, tokenId, event) => {
console.log(`${ from } => ${ to }: ${ tokenId }`)
// Optionally, convenience method to stop listening
event.removeListener();
});
}
The nft was correctly minted on the blockchain with the correct Transfer event.
But on the browser console I get this [object Object] => undefined: undefined
Any tips?