Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
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.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