Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rainbow-me/fee-suggestions

Package Overview
Dependencies
Maintainers
8
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainbow-me/fee-suggestions

JavaScript library that suggest fees on Ethereum after EIP-1559 using historical data using ethers.js

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

🔥 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:

  • maxBaseFee and maxPriorityFee suggestions
  • baseFeeTrend indicator
  • currentBaseFee which is the current block base fee
  • confirmationTimeByPriorityFee an object containing estimated times of confirmation by priority fee chosen
  • blocksToConfirmationByPriorityFee an object containing estimated blocks of wait for a confirmation by priority fee chosen
  • blocksToConfirmationByBaseFee an 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/

Keywords

FAQs

Package last updated on 22 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc