Search code examples
ethereumsolidity

How do I get topics to be human readable, after filtering events with ethers.js


I'm working in Ethereum with events.

I can get the events using this code (https://docs.ethers.io/v5/concepts/events/#events--filters)

But I just get topics, how do I turn the topics back to a human readable format.

const App = await ethers.getContractFactory("app");
let app = await App.attach(addressOfContract);
const logs = await app.filters.trustAdded(owner.address);

{
  address: 'addressOfContract',
  topics: [
    '0x9229966fc31285cf68748b91cfbc30dc196a49c2eaaf884d89125eb243aa211c',
    '0x000000000000000000000000996bf770d6027b7c1315637cda4dda684780bbde'
  ]
}

Solution

  • When you are are running the method attached to filters you are correct data that allows you to look up the events.

    const App = await ethers.getContractFactory("app");
    let app = await App.attach(addressOfContract);
    const logs = await app.filters.trustAdded(owner.address);
    **const _logs = await app.queryFilter(logs, 0)**
    

    _logs will have the value you are lookings for under .args