Transaction and VersionedTransaction objects. Includes automatic retry
logic for network reliability.
Use this when you need a fee estimate only. Use
simulateSolanaTransaction when you also
want to preview asset changes and security validation.
Installation
Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
transaction | Transaction | VersionedTransaction | The Solana transaction to estimate fees for |
networkData | NetworkData | Network configuration. Get this from getNetworksData() |
nativeTokenPriceUsd | number (optional) | USD price of SOL, used to calculate usdAmount |
Returns
Promise<SolanaTransactionFeeData>:
| Field | Type | Description |
|---|---|---|
nativeAmount | bigint | Fee in lamports |
humanReadableAmount | string | Fee in SOL, formatted for display |
usdAmount | string (optional) | Fee in USD. Present only when nativeTokenPriceUsd is provided |
Examples
SOL transfer fee
With USD conversion
Versioned transaction
Error handling
Related functions
- simulateSolanaTransaction - Full simulation with asset diffs and security validation
- calculateEvmTransactionFee - Fee estimation for EVM
- calculateFeeForUserOperation - Fee calculation for ZeroDev user operations
- getNetworksData - Get network configuration objects