0.0.19 • Published 8 months ago

bullet-proof-gas v0.0.19

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Bullet Proof Gas

To everyone troubled by the gas fees on Polygon

Overview

I have reimplemented Metamask's gas-fee-controller and provided a thin wrapper so that it can be called from various Web3 libraries.

Simply put, you can use the same gas fee calculation in Viem and Ethers as you do in Metamask.

https://github.com/MetaMask/core/tree/main/packages/gas-fee-controller

Installation

npm install bullet-proof-gas

Usage

Viem

import { fetchAndCalculateGasViaFeeHistory } from "bullet-proof-gas";
import { createPublicClient, http } from "viem";
import { polygon } from "viem/chains";

const publicClient = createPublicClient({
	transport: http(),
	chain: polygon,
});

const suggestedGas = await fetchAndCalculateGasViaFeeHistory(publicClient);

...

const walletClient = createWalletClient({
    ...
});

const tx = walletClient.sendTransaction({ ...suggestedGas.high });

EthersV5

import { fetchAndCalculateGasViaFeeHistory } from "bullet-proof-gas/ethers5";
import { ethers } from "ethers";

const provider = new ethers.providers.JsonRpcProvider(polygon.rpcUrls.default.http[0]);
const suggestedGas = await fetchAndCalculateGasViaFeeHistory(provider);

...

EthersV6

import { fetchAndCalculateGasViaFeeHistory } from "bullet-proof-gas/ethers6";
import { ethers as ethers6 } from "ethers-v6";

const provider = new ethers6.JsonRpcProvider(polygon.rpcUrls.default.http[0]);
const suggestedGas = await fetchAndCalculateGasViaFeeHistory(provider);

Super Thanks

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago