Estimating Priority Fees using Account Keys
Guide for estimating priority fees using account keys with the Helius Priority Fee API
Overview
This guide demonstrates how to estimate priority fees using account keys with the Helius Priority Fee API. While using serialized transactions provides more accurate estimates, the account keys approach offers a simpler alternative when you need quick fee estimates or want to estimate fees before constructing the full transaction.
When to Use Account Keys
The account keys approach is useful in these scenarios:
- Pre-transaction planning: When you need fee estimates before constructing the complete transaction
- Simplified integration: When your app architecture makes it difficult to serialize transactions before estimating fees
- Quick market analysis: When you want to analyze fee markets for specific accounts without building actual transactions
- Multi-account analysis: When you need to understand fee patterns across multiple accounts independently
Implementation Steps
1. Identify Relevant Accounts
Determine which accounts will be involved in your transaction:
2. Call the Priority Fee API
Make a request to the Helius Priority Fee API with the account keys:
3. Apply the Fee Estimate
After receiving the fee estimate, use it to set the priority fee in your transaction:
Complete Example
Here’s a complete example to fetch fee estimates for a set of account keys:
Working with Different Account Types
The fee estimates can vary significantly depending on account types and their activity:
Program Accounts
Program accounts typically have high transaction volumes and may show higher priority fees:
User Wallets
Active user wallets may have different fee patterns:
Advanced Options
Empty Slot Evaluation
The evaluateEmptySlotAsZero
option is particularly useful for account-based fee estimation:
When evaluateEmptySlotAsZero
is true
(default), slots with no transactions for a particular account are treated as having zero fees, rather than being excluded from the calculation. This is especially helpful for accounts with sparse transaction history, providing more balanced fee estimates.
Including Details
You can request detailed information about each account’s fee patterns:
Custom Lookback Period
Adjust the number of slots analyzed for fee estimation:
A smaller lookback period provides more recent market data but may be less stable, while a larger lookback provides more historical context.