Building Transaction Messages
Compose versioned transaction messages with fee payer, lifetime, and instructions.
Search across all documentation pages
Compose versioned transaction messages with fee payer, lifetime, and instructions.
Quick-reference recipe card - copy-paste ready.
import {
createTransactionMessage,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstruction,
} from "@solana/kit";When to reach for this:
import {
createSolanaRpc,
createTransactionMessage,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstructions,
address,
} from "@solana/kit";
import {
getSetComputeUnitLimitInstruction,
getSetComputeUnitPriceInstruction,
} from "@solana-program/compute-budget";
const rpc = createSolanaRpc(process.env.RPC_URL!);
const { value: blockhash } = await rpc.getLatestBlockhash().send();
const budgetIxs = [
getSetComputeUnitLimitInstruction({ units: 200_000 }),
getSetComputeUnitPriceInstruction({ microLamports: 5_000n }),
];
const message = pipe(
createTransactionMessage({ version: 0 }),
(m) => setTransactionMessageFeePayerSigner(walletSigner, m),
(m) => setTransactionMessageLifetimeUsingBlockhash(blockhash, m),
(m) => appendTransactionMessageInstructions(budgetIxs, m),
(m) => appendTransactionMessageInstructions(programIxs, m)
);What this demonstrates:
pipe keeps transforms readable and immutable.| Step | API |
|---|---|
| Version | createTransactionMessage({ version: 0 }) |
| Fee payer | setTransactionMessageFeePayerSigner |
| Lifetime | setTransactionMessageLifetimeUsingBlockhash |
| Instructions | appendTransactionMessageInstruction(s) |
| Alternative | Use When | Don't Use When |
|---|---|---|
| Codama builders | Typed program ixs | One-off system transfer |
| gill helpers | Faster bootstrap | Custom account metas |
CLI solana transfer | Manual SOL send | App integration |
Yes - point RPC and wallet at the same cluster.
Avoid in one module - migrate wholesale per route.
Wallets provide signers; kit builds messages.
Lock 7.0.0 in package.json and CI.
Compute budget instructions before send.
Surfpool 0.12.0 or local validator with devnet clones.
Always bigint lamports in kit code.
confirmed for UI; finalized for treasury.
Reads on server; signing in client components.
Simulate, read logs, verify account owners.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 19, 2026