Transactions and Instructions
Instructions compose into transactions submitted to the cluster. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not. On-chain samples are Rust; client samples use TypeScript where noted.
Build an instruction with program, accounts, data.
// Instruction { program_id, accounts, data }
Sign with fee payer and required signers.
// let mut tx = Transaction::new_with_payer(&[ix], Some(&payer.pubkey()));
// tx.sign(&[&payer], blockhash)
Transactions reference a recent blockhash for expiry.
// let blockhash = rpc.get_latest_blockhash()?
Set CU limit/price via compute budget program.
// ComputeBudgetInstruction::set_compute_unit_limit(200_000)
// ComputeBudgetInstruction::set_compute_unit_price(1_000)
v0 messages support ALTs.
// VersionedTransaction::try_new(message, &signers)
Serialize instruction payload.
// data: borsh::to_vec(&MyIx::Transfer { amount })?
Atomic: all succeed or all fail.
// Transaction::new_with_payer(&[ix1, ix2], Some(&payer))
Multisig / wallet partial signatures.
// tx.try_partial_sign(&[&kp], blockhash)
Signatures cover message bytes.
Nonce accounts for offline/long-lived txs.
// advance nonce + use durable nonce blockhash
CU price increases inclusion priority.
// set_compute_unit_price(micro_lamports)
Address lookup tables compress account lists.
// v0::Message::try_compile(..., &[alt], blockhash)
SimulateTransaction before send for logs/CU.
// rpc.simulate_transaction(&tx)
Optional skip - prefer preflight in dev.
// send_and_confirm with preflight enabled by default
confirmed vs finalized trade latency/finality.
// CommitmentConfig::confirmed()
Stack versions: This page was written for Agave 4.1.1 , Solana CLI 3.0.10 , Anchor 0.32.1 , Rust 1.91.1 , and @solana/kit 7.0.0 .
Y29kZWd1aWRlcy5pb3xjZ2lvMzI5fDIwMjYwNw==