Compiles a DRAFT transaction to wire format, transitioning it to COMPILED state. If recent_blockhash is not supplied, the service fetches the latest blockhash automatically — this is the standard pattern.
After compilation, instructions cannot be added or removed. The instructions field on the returned transaction is no longer the source of truth — the transaction is now encoded in data.
Request
transaction
Transaction (object)
required
Draft transaction in DRAFT state containing the instructions to compile. Instructions to include in the transaction (only relevant in DRAFT state).
config
TransactionConfig (object)
Optional compute budget configuration. Show TransactionConfig fields
Max compute units for the transaction.
Price per compute unit in microlamports.
Priority fee in lamports.
If true, skip preflight simulation before submission.
If true, skip account validation during submission.
fee_payer
Base58-encoded public key (string)
required
Address that will pay transaction fees.
recent_blockhash
Base58-encoded string (optional)
Optional. If empty, the service fetches the latest blockhash. Supply only for durable nonce transactions.
Response
The compiled transaction in COMPILED state. TRANSACTION_STATE_COMPILED (2) after successful compilation.
Compiled transaction bytes. The source of truth once the transaction is in COMPILED or later state.
The blockhash used during compilation. Transactions expire ~150 slots after their blockhash.
Code Examples
// Assume txn is a Transaction in DRAFT state with instructions already set
resp , err := client . CompileTransaction ( ctx , & transaction_v1 . CompileTransactionRequest {
Transaction : txn ,
FeePayer : "YourFeePayer111111111111111111111111111111" ,
// recent_blockhash omitted — service fetches latest automatically
})
if err != nil {
log . Fatal ( err )
}
compiled := resp . Transaction
fmt . Printf ( "State: %v \n " , compiled . State )