The SDK determines the most efficient priority fees for Solana transactions by analyzing recent network priority fees of writable accounts. Priority fee is recommended via the Langchain framework. Reduces Solana transaction fees by up to 50%.
Note: It is currently in beta phase. While suitable for testing and evaluation purposes, it is not recommended for production environments.
npm install solana-priority-fees
Create a .env
file with the following content
XAI_API_KEY="Your XAI API KEY"
You can get the XAI_API_KEY
(Grok API), by authorising your X Account. It is offering 25$ worth of credits as per December 2024.
Step 1 - Initialize
import { SolanaPriorityFees } from 'ai-fee';
const priorityFees = new SolanaPriorityFees({
xAiApiKey: process.env.XAI_API_KEY
});
Step 2 - Define the writable account addresses of your transactions
const accountKeys=['writable-account-keys-list'];
Step 3 - Get Recommended Fees
const fee = await priorityFees.getPrioritizationFees(accountKeys);