Skip to main content

getGasPrice

Callable

  • getGasPrice<ReturnFormat>(web3Context: Web3Context<EthExecutionAPI, any>, returnFormat: ReturnFormat): Promise<NumberTypes[ReturnFormat[number]]>

  • Type parameters

    • ReturnFormat: DataFormat

    Parameters

    • web3Context: Web3Context<EthExecutionAPI, any>

      (Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.

    • returnFormat: ReturnFormat

      (DataFormat defaults to DEFAULT_RETURN_FORMAT) Specifies how the return data should be formatted.

    Returns Promise<NumberTypes[ReturnFormat[number]]>

    The gas price determined by the last few blocks median gas price.

    web3.eth.getGasPrice().then(console.log);
    > 20000000000n

    web3.eth.getGasPrice({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
    > "0x4a817c800"