Ethers.js: Can You Get the Transaction Hash from a PairCreated Event?

ethers.js

When searching for newly created tokens using factory.on("PairCreated", async (token0, token1, addressPair) is there any way to get the Txn Hash of each new pair to use in conjunction with .getTransactionReceipt?

Best Answer

is there any way to get the Txn Hash of each new pair to use in conjunction with .getTransactionReceipt ?

Yes, just use :

factory.on("PairCreated", async (token0, token1, addressPair, event) => {});

And you can read the tx hash in event.transactionHash or call event.getTransactionReceipt directly.

Related Topic