This guide explores how to utilize Jito Bundles on the Solana blockchain, enabling atomic and sequential execution of multiple transactions within the same block. It includes practical code examples using TypeScript and Solana Web3.js 2.0.
Overview
As demand for Solana block space grows, ensuring transaction inclusion becomes critical. Many applications require multiple transactions to execute atomically and sequentially. Jito Labs, a team building high-performance MEV infrastructure for Solana, offers a unique Bundles feature via their validator client.
Key Objectives
- Install the Lil' JIT Marketplace Add-on
- Script creation using TypeScript and Solana Web3.js 2.0
- Build a 5-transaction bundle
- Submit the bundle to Jito’s validator client
- Verify transaction inclusion and order
Prerequisites
- QuickNode account
- Familiarity with optimizing Solana transactions
- Mainnet SOL (~0.01 SOL for demo)
- Latest Solana CLI tools
What Are Jito Bundles?
Jito Bundles allow atomic, sequential execution of multiple Solana transactions (up to 5 per bundle). Key features:
| Feature | Description |
|---|---|
| Sequential Execution | Transactions execute in the exact order specified. |
| Atomic Execution | All transactions either succeed or fail together. |
| All-or-Nothing | If one transaction fails, none are recorded on-chain. |
| Priority via Tips | Validators prioritize bundles with higher tip amounts. |
How Jito Bundles Work
- User creates/signs transactions.
- Bundles transactions with a tip instruction in the final transaction.
- Submits bundle to Jito’s block engine.
- Validators process bundles during block production.
Use Cases
- MEV Arbitrage: Bundle user trades with arbitrage transactions.
- Liquidations: Pair oracle updates with liquidation logic.
- Batch Operations: Overcome transaction size/compute limits.
Step-by-Step Implementation
1. Project Setup
Initialize a new project:
mkdir jito-bundle-demo && cd jito-bundle-demo
npm init -y
npm install @solana/web3.js@2 @solana-program/memo @solana-program/system 2. Script Development
Create index.ts with the following structure:
import {
createSolanaRpc,
createKeyPairSignerFromBytes,
// ... other imports
} from "@solana/web3.js";
import secret from "./secret.json";
// Constants
const ENDPOINT = 'https://your-quicknode-endpoint.quiknode.pro/';
const MIN_TIP = 1000; // lamports
async function main() {
// Step 1: Initialize signer and RPC clients
const signer = await createKeyPairSignerFromBytes(new Uint8Array(secret));
const rpc = createSolanaRpc(ENDPOINT);
// Step 2: Fetch Jito tip account
const tipAccount = await getRandomTipAccount(rpc);
// Step 3: Create and send bundle
const bundleId = await createAndSendBundle(signer, tipAccount);
console.log(`Bundle landed: https://explorer.jito.wtf/bundle/${bundleId}`);
}3. Bundle Creation
Generate transactions with memo instructions:
async function createTransactions(signer, tipAccount) {
const transactions = [];
for (let i = 0; i < 5; i++) {
const tx = await createMemoTransaction(
`Transaction #${i}`,
signer,
i === 4 ? tipAccount : null // Add tip to last TX
);
transactions.push(tx);
}
return transactions;
}4. Simulation & Submission
Validate and submit the bundle:
const simulation = await rpc.simulateBundle(transactions).send();
if (simulation.value.summary !== 'succeeded') throw Error("Simulation failed");
const bundleId = await rpc.sendBundle(transactions).send();
await pollBundleStatus(rpc, bundleId); // Confirm on-chain inclusionFAQs
Why use Jito Bundles over regular transactions?
Jito Bundles guarantee atomicity and order, critical for DeFi, MEV, and complex multi-step operations.
What’s the minimum tip amount?
1,000 lamports (0.000001 SOL). Higher tips increase priority.
Can bundles fail?
Yes. If any transaction fails (e.g., insufficient funds), the entire bundle reverts.
Conclusion
Jito Bundles enhance Solana transaction reliability for advanced use cases. By following this guide, you’ve learned to:
- Structure atomic transaction groups.
- Prioritize execution with tips.
- Verify on-chain inclusion.
👉 Explore more Solana developer tools
Resources: