Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Solana's leader schedule is fully deterministic for the next ~432k slots (~2 days). It's computed from stake weights at the start of each epoch (every 432k slots). This determinism enables clients to send transactions directly to the upcoming leader rather than gossiping — a major latency advantage over Ethereum's random-proposer model.
Send a tx directly to the current and next leaders.
getLeaderSchedule and identify the next 5 slot leaders.Use these three in order. Each builds on the one before.
In one paragraph, explain the Solana leader schedule and how it differs from Ethereum.
Walk me through the leader rotation — how stake weight maps to slot assignment.
Given a high-frequency trading bot that wants <100ms inclusion, design the TPU submission strategy to maximize landing rate.
import { Connection, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
const conn = new Connection(process.env.RPC_URL);
// Get the upcoming leader schedule
const slot = await conn.getSlot();
const leaderSchedule = await conn.getLeaderSchedule(slot);
// Returns { <validatorPubkey>: [slot1, slot2, ...] }
// Get current + next 2 leaders' TPU addresses
const clusterNodes = await conn.getClusterNodes();
const upcomingLeaders = []; // logic to find next 3 leaders from leaderSchedule
// Get their tpuQuic / tpu socket addresses
const upcomingTpus = upcomingLeaders.map(l => {
const node = clusterNodes.find(n => n.pubkey === l);
return node?.tpuQuic ?? node?.tpu;
}).filter(Boolean);
// Send transaction via UDP to all upcoming leaders simultaneously
// (RPC providers like Helius/Triton do this for you internally)
const tx = new Transaction().add(...);
tx.recentBlockhash = (await conn.getLatestBlockhash()).blockhash;
tx.sign(wallet);
const serialized = tx.serialize();
await Promise.all(upcomingTpus.map(tpu => sendUdpTx(serialized, tpu)));
// Why send to multiple: if leader N misses their slot, leader N+1 sees your tx
// Standard pattern: send to current + next 2 leaders for redundancy