Skip to content

Gas estimation failed #2

@kumargaurvdev

Description

@kumargaurvdev

hi i am trying it on BSC network and using https://api.owlracle.info/v3/bsc/gas this for gas

import { ChainId } from "@0x/contract-addresses";
import axios from "axios";
import { ethers } from "ethers";

export const getGasEstimation = async (chainId: ChainId) => {

if (chainId === ChainId.BSC) {
const gasEstimation = await (await axios.get('https://api.owlracle.info/v3/bsc/gas')).data['speeds'];
// solution presented at ethers-io/ethers.js#2828
const maxFeePerGas = ethers.utils.parseUnits(
Math.ceil(gasEstimation.maxFee) + '',
'gwei'
)
const maxPriorityFeePerGas = ethers.utils.parseUnits(
Math.ceil(gasEstimation.maxPriorityFee) + '',
'gwei'
)
return { maxFeePerGas, maxPriorityFeePerGas }
}

return {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions