1

How do I find the gas price of a confirmed transaction with ethers js?

2 Answers 2

4

getTransactionReceipt

gasUsed: { BigNumber: "443560" },

and the total cost of the transaction

  getTxCost = async (txHash) => {
        let receipt = await ethers.provider.getTransactionReceipt(txHash);
        return receipt.effectiveGasPrice.mul(receipt.gasUsed);
      };
1
  • To get the price in USD, do you take this output and multiply it by the price of ETH in USD? Also the units return from the function is in wei and not gwei right
    – wongx
    Commented May 10, 2022 at 18:50
1

provider.getTransaction([transactionHash])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.