Package Exports
- @liquality/fee-suggestions
- @liquality/fee-suggestions/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@liquality/fee-suggestions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🔥 EIP-1559 Fee Suggestions 🔥
The function suggestFees() is a utility function written in Javascript and it's intended to use with an ethers.js provider.
It returns an object containing:
maxBaseFeeandmaxPriorityFeesuggestionsbaseFeeTrendindicatorcurrentBaseFeewhich is the current block base feeconfirmationTimeByPriorityFeean object containing estimated times of confirmation by priority fee chosenblocksToConfirmationByPriorityFeean object containing estimated blocks of wait for a confirmation by priority fee chosenblocksToConfirmationByBaseFeean object containing estimated blocks of wait for a confirmation by base fee chosen
Usage
import { JsonRpcProvider } from '@ethersproject/providers';
import { suggestFees } from './src';
const main = async() => {
const provider = new JsonRpcProvider(`https://ropsten.infura.io/v3/${YOUR_API_KEY}`);
const ret = await suggestFees(provider);
console.log('Result: ', ret);
}
main();In addition, you can use specific methods to get maxBaseFee and maxPriorityFee specific data.
import { JsonRpcProvider } from '@ethersproject/providers';
import { suggestFees } from './src';
const main = async() => {
const provider = new JsonRpcProvider(`https://ropsten.infura.io/v3/${YOUR_API_KEY}`);
const fromBlock = 'latest' // the block that you want to run the estimations from
const blockCountHistory = 100 // the quantity of blocks you want to take in account for the estimation
const ret = await suggestMaxBaseFee(provider, fromBlock, blockCountHistory);
console.log('Result: ', ret);
}
main();import { JsonRpcProvider } from '@ethersproject/providers';
import { suggestFees } from './src';
const main = async() => {
const provider = new JsonRpcProvider(`https://ropsten.infura.io/v3/${YOUR_API_KEY}`);
const fromBlock = 'latest' // the block that you want to run the estimations from
const ret = await suggestMaxPriorityFee(provider, fromBlock, blockCountHistory);
console.log('Result: ', ret);
}
main();Credits
The suggestMaxBaseFee estimations code is 100% based on the work of @zsfelfoldi published at https://github.com/zsfelfoldi/feehistory/