Installation
Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
transaction | object | The transaction to estimate fees for |
transaction.from | string | The sender address |
transaction.to | string | The recipient or contract address |
transaction.value | bigint (optional) | Native token amount in wei |
transaction.data | string (optional) | Encoded contract call data |
networkData | NetworkData | Network configuration. Get this from getNetworksData() |
nativeTokenPriceUsd | number (optional) | USD price of the native token, used to calculate usdAmount |
Returns
Promise<EvmTransactionFeeData>:
| Field | Type | Description |
|---|---|---|
nativeAmount | bigint | Total fee in wei |
humanReadableAmount | string | Fee in ETH, formatted for display |
usdAmount | string (optional) | Fee in USD. Present only when nativeTokenPriceUsd is provided |
gasEstimate | bigint | Estimated gas units |
maxFeePerGas | bigint (optional) | EIP-1559 max fee per gas |
maxPriorityFeePerGas | bigint (optional) | EIP-1559 priority fee per gas |
gasPrice | bigint (optional) | Legacy gas price. Present when EIP-1559 is not available |
Examples
Simple ETH transfer
With USD conversion
Contract interaction
Error handling
Related functions
- simulateEvmTransaction - Full simulation with asset diffs and security validation
- calculateSolanaTransactionFee - Fee estimation for Solana
- calculateFeeForUserOperation - Fee calculation for ZeroDev user operations
- getNetworksData - Get network configuration objects