I'm starting to use anonymous events so i wrote a very simple contract just to see how it works and the problem is when I deploy my contract with a simple event i can get the arg of the events but when i make it anonymous, I can't access them.
the contract :
pragma solidity ^0.8.9;
contract Lock {
event DataStored(address admin, uint256 indexed data) anonymous;
uint256 data;
function storeData(uint256 data) external {
data = data;
emit DataStored(msg.sender, data);
}
}
the deploy.js
const hre = require("hardhat");
async function main() {
const Lock = await hre.ethers.getContractFactory("Lock");
const lock = await Lock.deploy();
await lock.deployed();
console.log(
` deployed to ${lock.address}`
);
tx = await lock.storeData(10);
const transactionReceipt = await tx.wait()
console.log(transactionReceipt.events[0])
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
event logs without anonymous keyword and with anonymous keyword are in the pictures.