with one click
fee-estimation
// Estimate EIP-1559 gas fees with Nethereum. Use when the user asks about gas fees, fee estimation, maxFeePerGas, maxPriorityFeePerGas, base fee, or choosing a fee strategy for transactions.
// Estimate EIP-1559 gas fees with Nethereum. Use when the user asks about gas fees, fee estimation, maxFeePerGas, maxPriorityFeePerGas, base fee, or choosing a fee strategy for transactions.
| name | fee-estimation |
| description | Estimate EIP-1559 gas fees with Nethereum. Use when the user asks about gas fees, fee estimation, maxFeePerGas, maxPriorityFeePerGas, base fee, or choosing a fee strategy for transactions. |
| user-invocable | true |
NuGet: Nethereum.RPC
Source: Fee1559SuggestionDocExampleTests
using System.Numerics;
using Nethereum.Hex.HexTypes;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.RPC.Fee1559Suggestions;
EIP-1559 splits gas fees into baseFee (protocol-set, burned) and priorityFee (tip to validator). Users set maxPriorityFeePerGas (tip ceiling) and maxFeePerGas (total ceiling). Actual cost = min(baseFee + priorityFee, maxFeePerGas).
Holds all fee components in a single object.
var fee = new Fee1559
{
BaseFee = 20_000_000_000,
MaxPriorityFeePerGas = 2_000_000_000,
MaxFeePerGas = 42_000_000_000
};
Fixed priority fee of 2 Gwei. MaxFee = 2 * baseFee + priorityFee. Fast, no RPC calls beyond latest block.
var defaultPriority = SimpleFeeSuggestionStrategy.DEFAULT_MAX_PRIORITY_FEE_PER_GAS;
// 2,000,000,000 (2 Gwei)
// Usage with Web3:
// var strategy = new SimpleFeeSuggestionStrategy(web3.Client);
// Fee1559 fee = await strategy.SuggestFeeAsync();
Uses eth_feeHistory to compute median priority fee from recent blocks. Applies a baseFee multiplier that decreases as baseFee rises.
var strategy = new MedianPriorityFeeHistorySuggestionStrategy();
strategy.GetBaseFeeMultiplier(30_000_000_000); // 2.0x (< 40 Gwei)
strategy.GetBaseFeeMultiplier(50_000_000_000); // 1.6x (40-100 Gwei)
strategy.GetBaseFeeMultiplier(150_000_000_000); // 1.4x (100-200 Gwei)
strategy.GetBaseFeeMultiplier(300_000_000_000); // 1.2x (>= 200 Gwei)
var feeHistory = new FeeHistoryResult
{
OldestBlock = new HexBigInteger(100),
BaseFeePerGas = new[]
{
new HexBigInteger(20_000_000_000),
new HexBigInteger(21_000_000_000)
},
GasUsedRatio = new decimal[] { 0.5m },
Reward = new[]
{
new[] { new HexBigInteger(1_000_000_000) },
new[] { new HexBigInteger(1_500_000_000) },
new[] { new HexBigInteger(2_000_000_000) },
new[] { new HexBigInteger(2_500_000_000) },
new[] { new HexBigInteger(3_000_000_000) }
}
};
var estimate = strategy.EstimatePriorityFee(feeHistory);
var maxPriorityFee = new BigInteger(2_000_000_000);
var baseFee = new HexBigInteger(30_000_000_000);
Fee1559 result = strategy.SuggestMaxFeeUsingMultiplier(maxPriorityFee, baseFee);
// result.MaxFeePerGas > baseFee (includes multiplier headroom)
// result.MaxPriorityFeePerGas == maxPriorityFee
Returns an array of Fee1559 suggestions factoring in urgency. Uses 100 blocks of fee history. Best for UIs offering slow/medium/fast options.
var strategy = new TimePreferenceFeeSuggestionStrategy();
// Build fee history (normally from eth_feeHistory RPC)
var feeHistory = new FeeHistoryResult
{
OldestBlock = new HexBigInteger(1000),
BaseFeePerGas = baseFees, // HexBigInteger[101]
GasUsedRatio = gasUsedRatio // decimal[100]
};
var tip = new BigInteger(2_000_000_000);
Fee1559[] fees = strategy.SuggestFees(feeHistory, tip);
foreach (var fee in fees)
{
// fee.MaxFeePerGas >= fee.MaxPriorityFeePerGas
}
Web3's TransactionManagerBase defaults:
TimePreferenceFeeSuggestionStrategy (NOT Simple)UseLegacyAsDefault = false)CalculateOrSetDefaultGasPriceFeesIfNotSet = trueOverride the strategy:
web3.TransactionManager.Fee1559SuggestionStrategy =
new SimpleFeeSuggestionStrategy(web3.Client);
Force legacy transactions:
web3.TransactionManager.UseLegacyAsDefault = true;
// Or provide GasPrice in TransactionInput — legacy is used automatically
| Strategy | RPC Calls | Best For | Accuracy |
|---|---|---|---|
| Simple | 1 (latest block) | Quick transactions, stable networks | Low |
| Median | 1 (eth_feeHistory) | General-purpose, backend services | Medium |
| TimePreference | 1 (eth_feeHistory, 100 blocks) | UI with slow/medium/fast options | High |
// Simple
var simple = new SimpleFeeSuggestionStrategy(web3.Client);
Fee1559 fee = await simple.SuggestFeeAsync();
// Median
var median = new MedianPriorityFeeHistorySuggestionStrategy(web3.Client);
Fee1559 fee = await median.SuggestFeeAsync();
// TimePreference
var timePref = new TimePreferenceFeeSuggestionStrategy(web3.Client);
Fee1559[] fees = await timePref.SuggestFeesAsync();
Help users create and run a local Ethereum development environment with .NET Aspire — DevChain node, blockchain indexer, Blazor explorer, and PostgreSQL. Use this skill when the user mentions Aspire DevChain template, nethereum-devchain, creating a local blockchain environment with Aspire, setting up DevChain with an explorer and indexer, or wants a single-command Ethereum dev environment with .NET. Also trigger when users mention dotnet new nethereum-devchain or Nethereum.Aspire.TemplatePack.
Help users verify Groth16 zero-knowledge proofs from Circom/snarkjs circuits using Nethereum.ZkProofsVerifier (.NET). Use this skill whenever the user mentions ZK proofs, Groth16, snarkjs, Circom, zero-knowledge verification, BN128 pairing, proof.json, verification_key.json, or public.json in a C#/.NET context.
Help users work with EIP-7864 Binary Merkle Tries for stateless Ethereum execution using Nethereum.Merkle.Binary (.NET). Use this skill whenever the user mentions binary trie, EIP-7864, stateless execution, stem nodes, binary Merkle, BasicDataLeaf, code chunking, BLAKE3, or Verkle-style trie structures in a C#/.NET context.
Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET). Use this skill whenever the user mentions sparse Merkle trees, SMT, Poseidon hashing, Celestia SMT, ZK-compatible state trees, nullifier sets, membership proofs, or PoseidonSmtHasher in a C#/.NET context.
Validate and perfect a Nethereum documentation section end-to-end. Use when working on docs sections (getting-started, core-foundation, signing, smart-contracts, defi, evm-simulator, devchain, account-abstraction, data-indexing, mud-framework, wallet-ui, consensus, client-extensions). Covers use case definition, NuGet README verification against source code with compilation, guide page creation, Claude Code plugin skill creation per use case, sidebar updates, and build verification. Trigger when user mentions validating docs, fixing a docs section, creating guides, or perfecting documentation for any Nethereum section.
Help users batch multiple calls into a single UserOperation and sponsor gas with paymasters using Nethereum Account Abstraction. Use when the user mentions batching transactions, atomic multi-call, approve-then-swap in one tx, gas sponsorship, paymasters, gasless transactions, verifying paymaster, deposit paymaster, or PaymasterConfig in .NET/C# with ERC-4337.