Hi, I’m Dung Huynh Duc . Nice to meet you.

About Me

With over a decade of experience under my belt as a full-stack developer, I've had the opportunity to spearhead project teams at tech startups in Vietnam, Thailand, Japan and Singapore. Additionally, I have worked as a freelance engineer for various companies based in Asia Pacific, Europe, and North America.

Presently, I serve the role of a Senior Full Stack Software Engineer at ACX. I am consistently committed to exploring and acquiring knowledge on emerging and popular technologies.

tx receipt
abi decoder

#TIL 28 - Decode receipt logs with ethers

blog_hero_#TIL 28 - Decode receipt logs with ethers
import { ethers } from 'ethers';

// create an interface with your abi
const iface = ACX__factory.createInterface(abi);

function decodeLogsByEsther(
  logs: Log[],
  contractAddress: string,
): Array<ethers.utils.LogDescription & { values?: any }> {
  logger.info('decodeLogsByEsther', logs);
  const decodedLogs = logs
    .filter((log) => log.address.toLowerCase() === contractAddress.toLowerCase()) // only check log if from same smart contract address
    .map((log) =>
      iface.parseLog({
        topics: log.topics,
        data: log.data,
      }),
    );
  logger.info('decodedLogs', JSON.stringify(decodedLogs, null, 2));
  return decodedLogs.filter(Boolean);
}