optimize-transactions
Optimize Your Transactions
This guide will help you optimize your FlashBlock transactions, improve success rates, and reduce costs.
Transaction Optimization Strategies
1. Choose the Nearest Server Endpoint
Selecting the geographically closest server will provide the lowest latency:
- North America Users: Use
http://ny.flashblock.trade
orhttp://slc.flashblock.trade
- Europe Users: Use
http://ams.flashblock.trade
orhttp://fra.flashblock.trade
- Other Regions: Choose the best endpoint based on network latency tests
2. Optimize Tip Amount
The tip amount directly affects transaction priority:
- Minimum Tip: 0.001 SOL
- Recommended Tip: 0.001 - 0.01 SOL (adjust based on network congestion)
- High Priority: 0.01+ SOL (urgent transactions)
4. Monitor Network Status
Before sending transactions, check:
- Solana network status
- Current network congestion
- Average transaction confirmation time
5. Transaction Structure Optimization
Correct Transaction Format
{
"transactions": [
"base64_encoded_transaction_1",
"base64_encoded_transaction_2"
]
}
Tip Instruction Example
// Add a tip transfer instruction to your transaction
const tipInstruction = SystemProgram.transfer({
fromPubkey: wallet.publicKey,
toPubkey: new PublicKey("FLaShB3iXXTWE1vu9wQsChUKq3HFtpMAhb8kAh1pf1wi"),
lamports: 1000000 // 0.001 SOL
});
6. 🧪 Sandwich Mitigation Feature
We have introduced a new feature to help mitigate sandwich attacks—without the need for the vote account method.
How It Works
In your Solana transaction, add any valid Solana public key that starts with jitodontfront
to any instruction. For example:jitodontfront1111111flashblockdottrade
or jitodontfront1111111flashblockdottrade
Any bundle containing a transaction with the jitodontfront
account will be rejected by the block engine unless that transaction appears first (at index 0) in the bundle.
Transactions and bundles that do not contain this account are not impacted by this change.
✅ Allowed bundle patterns:
[tx_with_dont_front, tip]
[tx_with_dont_front, arbitrage, tip]
❌ Disallowed bundle patterns:
[tip, tx_with_dont_front]
[txA_with_dont_front, txB_with_dont_front]
[txA_with_dont_front, txB_with_dont_front, tip]
[trade, tx_with_dont_front, arbitrage, tip]
📌 Important Points
- The account does not need to exist on-chain but must be a valid public key
- Mark the account as read-only to optimize landing speed
- (Optional) Use a unique variation of
jitodontfront
for your application (use your own pubkey), for example:jitodontfront1111111flashblockdottrade
jitodontfront1111111flashblockdottrade
- Supports AddressLookupTables
📋 Example
// Add the protection account to your transaction instruction
const dontFrontAccount = new PublicKey("jitodontfront1111111flashblockdottrade");
// Add to any instruction (recommended as read-only)
const protectedInstruction = {
programId: yourProgramId,
keys: [
{ pubkey: dontFrontAccount, isSigner: false, isWritable: false }, // read-only
// ... other accounts
],
data: instructionData
};
Performance Optimization Tips
1. Connection Optimization
- Use persistent HTTP connections
- Enable connection reuse
- Set reasonable timeout values
- Send a ping request every 30 seconds
2. Error Handling
try {
const response = await fetch('http://ny.flashblock.trade/api/v2/submit-batch', {
method: 'POST',
headers: {
'Authorization': authHeader,
'Content-Type': 'application/json'
},
body: JSON.stringify({ transactions: batch })
});
const result = await response.json();
if (result.success) {
console.log('Batch submitted successfully:', result.data);
} else {
console.error(`Error: ${result.message} (Code: ${result.code})`);
}
} catch (error) {
console.error('API request failed:', error);
throw error;
}
Cost Optimization
1. Tip Strategy
- Adjust the tip based on transaction urgency
- Use the minimum tip for non-urgent transactions
- Dynamically adjust based on network congestion
Troubleshooting
1. Transaction Failure
- Check if the tip is sufficient
- Verify transaction format
- Confirm network connection
2. High Latency
- Switch to a closer endpoint
- Increase the tip amount
- Check network status
3. High Cost
- Optimize batch size
- Adjust tip strategy
- Choose the appropriate time window
Best Practices Summary
- Always use the nearest server endpoint
- Dynamically adjust the tip based on network status
- Implement a reasonable retry mechanism
- Monitor key performance indicators
- Optimize transaction batch size
- Maintain robust error handling in your code
By following these optimization strategies, you will significantly improve transaction success rates, reduce latency, and optimize cost efficiency.