ethers.js v5 기준
const contract = await ethers.getContractAt("DasomOLIContract", contract_address);
// DasomEvent(type arg1, ...)
const filter = contract.filters.DasomEvent();
const currentBlock = await ethers.provider.getBlockNumber();
const fromBlock = currentBlock - 86400;
const events = await ethers.provider.getLogs({
...filter,
fromBlock: fromBlock,
toBlock: currentBlock,
});
if (events.length > 0) {
events.forEach((event: Log) => {
console.log(`Dasom event found in block ${event.blockNumber}:`);
console.log(`Transaction Hash: ${event.transactionHash}`);
console.log(`Transaction data: ${event.data}`);
const parsedLog = contract.interface.parseLog(event);
const args = parsedLog.args;
const arg1 = args.arg1;
console.log(`Log Data:`, parsedLog.args);
console.log('--------------------------');
});
}