Gas-Price

如何使用 ethers js 找到已確認交易的 gasPrice?

  • January 9, 2022

如何使用 ethers js 找到已確認交易的 gas 價格?

獲取交易收據

gasUsed: { BigNumber: “443560” },

以及交易的總成本

 getTxCost = async (txHash) => {
       let receipt = await ethers.provider.getTransactionReceipt(txHash);
       return receipt.effectiveGasPrice.mul(receipt.gasUsed);
     };

provider.getTransaction([transactionHash])

引用自:https://ethereum.stackexchange.com/questions/92353