Get maxFeePerGas and maxPriorityFeePerGas using getGasInEIP1559 method
Web3Client web3 = Web3Client(network.rpc, httpClient);
Map<String, EIP1559Information> gasEIP = await web3.getGasInEIP1559();
// result: {'slow': EIP1559Information, 'medium': EIP1559Information, 'fast': EIP1559Information}
// Choose the speed rate you want, for example (medium)
EIP1559Information gasEIPInfo = gasEIP['medium']!;
// Finally, set the gas fee of your choice
Transaction tx = Transaction(
maxPriorityFeePerGas: gasEIPInfo.maxPriorityFeePerGas,
maxFeePerGas: gasEIPInfo.maxFeePerGas,
);
Get fee history from some blocks
// Count of blocks
int historicalBlocks = 10;
Map<String, dynamic> feeHistory = await web3.getFeeHistory(
historicalBlocks,
atBlock: BlockNum.pending(),
rewardPercentiles: [25, 50, 75], // percentage of fill
);
EtherAmount able to get value by decimals ( To handle different decimals of tokens )
EtherAmount acceptable datatypes of string, int, double or BigInt
int tokenDecimals = 9;
EtherAmount amount = EtherAmount.fromUnitAndValue(
EtherAmount.getUintDecimals(tokenDecimals),
100.65658,
);
// Get value in decimals
amount.getValueInDecimals(tokenDecimals)
// result: 100.65658
Get maxFeePerGas and maxPriorityFeePerGas using getGasInEIP1559 method
Get fee history from some blocks
EtherAmount able to get value by decimals ( To handle different decimals of tokens ) EtherAmount acceptable datatypes of string, int, double or BigInt