Skip to main content
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.
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

transaction
Transaction (object)
The compiled transaction in COMPILED state.

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)