getFeeData - SDK
Returns the recommended fee data to use in a transaction. For an EIP-1559 transaction, the maxFeePerGas and maxPriorityFeePerGas should be used. For legacy transactions and networks which do not support EIP-1559, the gasPrice should be used.
Returns the recommended fee data to use in a transaction. For an EIP-1559 transaction, the maxFeePerGas
and maxPriorityFeePerGas
should be used.
For legacy transactions and networks which do not support EIP-1559, the gasPrice
should be used.
Don’t have an API key?
Start using this method in your app today. Get started for free
Description
Returns the recommended fee data to use in a transaction. For an EIP-1559 transaction, the maxFeePerGas
and maxPriorityFeePerGas
should be used.
For legacy transactions and networks which do not support EIP-1559, the gasPrice
should be used.
Response
FeeData
response object parameters
Example Request and Response
Prerequisite: You will need to install the Alchemy SDK before making requests with it.
The commands for installing it using npm or yarn are given below:
Request
Here is an example of how to make a getFeeData
request using the Alchemy SDK:
Response
Use Cases
Here are some possible use cases for the getFeeData
method:
-
Transaction fee estimation: Developers can use the
getFeeData
method to estimate the fee required for a particular transaction. This information can be used to determine the optimal fee to set for a transaction, given the current network conditions. -
Gas price monitoring: The
getFeeData
method can be used to monitor changes in the gas price of a blockchain network over time. This information can be used to adjust gas price strategies for applications, ensuring they stay competitive and cost-effective. -
Smart contract development: When developing smart contracts, developers need to ensure that their contracts operate within the gas limits of the network. The
getFeeData
method can be used to calculate the gas costs associated with specific operations, helping developers to optimize their contract code and stay within network constraints.
Related Methods
Here are the methods related to getFeeData
:
- getGasPrice: Returns the current price per gas in
wei
.