web3dart_get_fee_data 1.0.2 copy "web3dart_get_fee_data: ^1.0.2" to clipboard
web3dart_get_fee_data: ^1.0.2 copied to clipboard

A Dart package for getting Ethereum fee data, including support for EIP-1559 transactions. Provides an easy-to-use API similar to ethers.js getFeeData().

web3dart_get_fee_data #

A Dart package for retrieving Ethereum fee data with full EIP-1559 support. Provides an API similar to ethers.js getFeeData().

pub package License: MIT

Features #

  • EIP-1559 Support: Get maxFeePerGas and maxPriorityFeePerGas
  • Legacy Compatibility: Automatic fallback to gasPrice
  • Network Detection: Handles both EIP-1559 and legacy networks
  • Type Safe: Full Dart type safety with nullable types

Installation #

Add this package to your pubspec.yaml:

dependencies:
  web3dart_get_fee_data: ^1.0.2

Then run:

dart pub get

Usage #

import 'package:web3dart/web3dart.dart';
import 'package:web3dart_get_fee_data/web3dart_get_fee_data.dart';
import 'package:http/http.dart';

void main() async {
  final httpClient = Client();
  final ethClient = Web3Client('https://eth.llamarpc.com', httpClient);

  try {
    final feeData = await getFeeData(ethClient);

    if (feeData.maxFeePerGas != null) {
      print('EIP-1559: ${feeData.maxFeePerGas} wei');
    } else {
      print('Legacy: ${feeData.gasPrice} wei');
    }
  } finally {
    ethClient.dispose();
  }
}

API #

getFeeData(Web3Client client) #

Returns Future<FeeData> with current network fees.

FeeData #

Property Type Description
gasPrice BigInt? Legacy gas price in wei
maxFeePerGas BigInt? EIP-1559 max fee per gas
maxPriorityFeePerGas BigInt? EIP-1559 priority fee

Network Support #

EIP-1559 Networks: Returns all three properties
Legacy Networks: Returns only gasPrice

License #

MIT License - see LICENSE file.

0
likes
160
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package for getting Ethereum fee data, including support for EIP-1559 transactions. Provides an easy-to-use API similar to ethers.js getFeeData().

Repository (GitHub)
View/report issues

Topics

#ethereum #web3 #blockchain #gas #eip-1559

Documentation

API reference

License

MIT (license)

Dependencies

http, wallet, web3dart

More

Packages that depend on web3dart_get_fee_data