在使用 ethers.js 过滤事件后,如何让主题变得易于阅读

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

我正在以太坊中处理事件。

我可以使用此代码获取事件 (https://docs.ethers.io/v5/concepts/events/#events--filters)

但我只是获取主题,如何将主题恢复为人类可读格式。

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'
  ]
}

当您是 运行 附加到过滤器的方法时,您就是允许您查找事件的正确数据。

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 将具有您在 .args

下寻找的值