Skip to main content
Estimates the compute units and fees required to execute a compiled transaction. This is a read-only call — it does not change transaction state.
Estimates are based on current network conditions and may change between estimation and submission. To apply estimates: set config.compute_unit_limit and config.compute_unit_price on the transaction before signing.

Request

transaction
Transaction (object)
required
A compiled transaction in COMPILED state.
commitment_level
CommitmentLevel (enum)
Optional. Commitment level used for priority fee lookup. Defaults to CONFIRMED.
commitment_level is optional. When omitted or set to COMMITMENT_LEVEL_UNSPECIFIED, the service defaults to COMMITMENT_LEVEL_CONFIRMED. See CommitmentLevel for trade-offs between processed, confirmed, and finalized.

Response

compute_units
uint64
Estimated compute units required to execute this transaction.
fee_lamports
uint64
Estimated total transaction fee in lamports, including base fee and priority fee.
priority_fee
uint64
Estimated current network priority fee in lamports based on recent network conditions.

Code Examples

resp, err := client.EstimateTransaction(ctx, &transaction_v1.EstimateTransactionRequest{
    Transaction: compiledTxn,
})
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Compute units: %d\n", resp.ComputeUnits)
fmt.Printf("Fee: %d lamports\n", resp.FeeLamports)
fmt.Printf("Priority fee: %d lamports\n", resp.PriorityFee)