A comprehensive TypeScript project demonstrating the efficiency benefits of using Solana Address Lookup Tables (ALTs) for transaction optimization, specifically focused on PumpFun token purchases and bundle transactions.
This project showcases how Solana Address Lookup Tables can significantly reduce transaction sizes and improve network efficiency. It provides practical implementations for:
- Single token purchases with and without lookup tables
- Bundle transactions for multiple buyers
- Performance comparison and analysis tools
- Real-world PumpFun integration examples
- Automatic comparison between normal and lookup table transactions
- Detailed analytics showing byte savings and efficiency gains
- Performance metrics with percentage reductions and compression ratios
- Single buyer transactions - Individual token purchases
- Bundle transactions - Multiple buyers in one transaction
- Lookup table creation - Automated ALT setup and management
- Transaction executor with simulation and retry logic
- Comprehensive logging with detailed transaction analysis
- Error handling and recovery mechanisms
solana-transaction-optimizer/
βββ index.ts # Main entry point with single buyer examples
βββ bundle_buys.ts # Bundle transaction implementations
βββ single_buy_comparison.ts # Detailed comparison analysis
βββ createLookupTable.ts # Lookup table creation utilities
βββ txsExecutor.ts # Transaction execution helper
βββ buyersKeys.ts # Configuration for multiple buyers
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
-
Clone the repository
git clone <repository-url> cd solana-transaction-optimizer
-
Install dependencies
npm install
-
Environment setup Create a
.envfile with your configuration:SIGNER_KEY=your_base58_encoded_private_key
SIGNER_KEY: Your wallet's private key in base58 format
The project uses several hardcoded addresses that you may need to update:
// Main configuration in index.ts and other files
const lookup_address = new PublicKey("E4b5B9C3hapUZY7qfbLXTsPdaRzUT1HbT7uGRS19DXyL");
const program_id = new PublicKey("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
const mint = new PublicKey("9rwU5ex3PAp6TZ4PQ68nnGHtcRmnD5Hyo4QzYWZVpump");
const creator = new PublicKey("Gqd1HsMwhNMHtqL1iZ2M23DriBPJdnbJR8PEBUCPDvB");Edit buyersKeys.ts to add wallet private keys for bundle transactions:
export const privateKeys = [
"wallet1_private_key_base58",
"wallet2_private_key_base58",
// Add more wallets as needed
];Run the main comparison analysis:
npx ts-node single_buy_comparison.tsThis will:
- Create a normal transaction without lookup table
- Create the same transaction with lookup table
- Display detailed comparison metrics
- Show efficiency gains and recommendations
Execute bundle purchases with multiple buyers:
npx ts-node bundle_buys.tsRun specific functions from index.ts:
npx ts-node index.tsThe project provides comprehensive performance metrics with real-world examples:
TRANSACTION SIZES:
Normal Transaction: 660 bytes
With Lookup Table: 353 bytes
Absolute Savings: 307 bytes
EFFICIENCY METRICS:
Size Reduction: 46.5%
Efficiency Gain: 87.0%
Compression Ratio: 1.87:1
TRANSACTION SIZES:
Normal Bundle: 1536+ bytes (FAILED - exceeds 1232 byte limit)
With Lookup Table: 871 bytes (SUCCESS)
Absolute Savings: 665+ bytes
EFFICIENCY METRICS:
Size Reduction: 43.3%+
Status: From FAILED to SUCCESS
Network Impact: Enables complex bundle transactions
Bundle Transaction Success: View on Solscan
- This transaction demonstrates successful bundle execution using lookup tables
- Multiple buyers in a single transaction that would otherwise fail due to size limits
- EXCELLENT: >50% reduction - Highly effective
- GOOD: 30-50% reduction - Solid benefits
- MODERATE: 15-30% reduction - Decent improvement
- MINIMAL: <15% reduction - May not justify complexity
Address Lookup Tables can reduce transaction sizes by 40-90%, making them essential for:
- Bundle Transactions: Enabling multiple operations that would otherwise fail due to size limits
- Complex DeFi Operations: Reducing costs and improving success rates
- High-Frequency Trading: Optimizing transaction throughput
- Gaming Applications: Supporting complex in-game transactions
@solana/web3.js: Core Solana blockchain interaction@solana/spl-token: Token program utilitieslatest-pumpfun-sdk: PumpFun protocol integrationbn.js: Big number handlingbs58: Base58 encoding/decodingdotenv: Environment variable management
const createLUT = async (mainKP: Keypair, connection: Connection) => {
// Creates lookup table with retry logic
// Includes compute budget optimization
// Handles slot-based creation
}const createAndSendV0Tx = async (
txInstructions: TransactionInstruction[],
kp: Keypair,
connection: Connection
) => {
// Versioned transaction creation
// Simulation and error handling
// Automatic retry mechanism
}- Supports multiple buyers in single transaction
- Automatic ATA (Associated Token Account) management
- Optimized lookup table population
- Comprehensive error handling
- DEX aggregators reducing transaction sizes by 40-90%
- Yield farming with multiple token operations
- Liquidity provision with complex account structures
- Bundle swaps across multiple protocols
- Bundle purchases of multiple NFTs in single transaction
- Bulk operations with reduced transaction costs
- Marketplace efficiency improvements
- Collection-wide operations (listing, delisting, transfers)
- In-game transactions with multiple assets
- Player actions requiring multiple account interactions
- Economy optimization for better user experience
- Batch operations for inventory management
- Multi-buyer transactions (as demonstrated in our examples)
- Arbitrage opportunities requiring multiple operations
- Liquidity provision across multiple pools
- Complex trading strategies that exceed normal size limits
- Never commit private keys to version control
- Use environment variables for sensitive data
- Test on devnet before mainnet deployment
- Lookup table creation requires ~15 seconds to activate
- Account rent costs for lookup table storage
- Authority management for table updates
- Maximum 256 addresses per lookup table
- Immutable once created (addresses cannot be removed)
- Slot-based creation timing requirements
To include additional accounts in your lookup table:
// Add to the accounts array in your lookup table creation
accounts.push(
new PublicKey("your_new_account_address"),
// Add more accounts as needed
);Update the transaction creation logic in the respective files:
index.tsfor single buyer transactionsbundle_buys.tsfor multiple buyer transactionssingle_buy_comparison.tsfor analysis functions
- Batch Operations: Group related transactions to maximize lookup table efficiency
- Account Reuse: Include frequently used accounts in lookup tables
- Monitor Usage: Track lookup table effectiveness for your specific use case
- Optimize Timing: Create lookup tables during low-traffic periods
- Bundle Strategy: Use lookup tables for bundle transactions to avoid size limit failures
- Size Monitoring: Track transaction sizes to identify optimization opportunities
- Bundle transactions that previously failed (1536+ bytes) now succeed (871 bytes)
- Single transactions reduced from 660 to 353 bytes (46.5% reduction)
- Network efficiency improved through reduced bandwidth usage
- User experience enhanced with faster, more reliable transactions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source and available under the MIT License.
For questions, issues, or contributions:
- Create an issue in the repository
- Check existing documentation
- Review Solana's official lookup table documentation
Note: This project is for educational and development purposes. Always test thoroughly on devnet before using on mainnet, and ensure you understand the implications of lookup table usage for your specific application.