dart_web3gas 0.0.3 copy "dart_web3gas: ^0.0.3" to clipboard
dart_web3gas: ^0.0.3 copied to clipboard

outdated

Calculate gas fees based on web3art. Refer to metamask for the calculation method.

example/main.dart

import 'dart:io';

import 'package:dart_web3gas/web3dart/web3dart.dart';

import 'package:dart_web3gas/dart_web3gas.dart';

Future<void> main() async {
  var http = HttpClient();
  http.connectionTimeout = const Duration(seconds: 2);
  {
    var web3 =
        Web3Client.custom(JsonRPCHttp('https://polygon.llamarpc.com', http));
    var gas = await GasFeeController.fetchGasFeeEstimateData(web3);
    var max = gas?.gasFeeEstimates?.medium.suggestedMaxFeePerGas;
    var priority = gas?.gasFeeEstimates?.medium.suggestedMaxPriorityFeePerGas;

    var basefee = await web3.estimateGas(
        sender: EthereumAddress.fromHex(
            '0xf17C8F3ADb9DEB7E3D4a23E66Fd2f4838349739b'),
        to: EthereumAddress.fromHex(
            '0xf17C8F3ADb9DEB7E3D4a23E66Fd2f4838349739b'));
    if (max != null && priority != null) {
      print('basefee: $basefee');
      print(
          'max:${double.parse(max) * basefee.toDouble()} pri:${double.parse(priority) * basefee.toDouble()}');
    }
  }
}
1
likes
0
points
76
downloads

Publisher

unverified uploader

Weekly Downloads

Calculate gas fees based on web3art. Refer to metamask for the calculation method.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

convert, eip55, http, json_annotation, json_rpc_2, json_serializable, logger, pointycastle, sec, stream_channel, stream_transform, typed_data, uuid

More

Packages that depend on dart_web3gas