1

I'm trying to calculate in ethers.js the cost of a transaction on BSC. I found on another thread the following snippet of code:

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

but the problem is that effectiveGasPrice seems to not exist on BSC. How can I get this value? Thanks

1 Answer 1

0

face the same issue today. Not the best solution, but i get the value via https://docs.ethers.io/v5/api/providers/provider/#Provider-getGasPrice

gasPrice = await provider.getGasPrice()

From bscscan, the value seems to be quite constant, 5 Gwei. But still, this is just a best guess of gasPrice. Hopefully there will be a better solution soon.

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.