Compute Budget

Every Solana transaction has a compute budget measured in Compute Units (CU). Understanding CU costs helps you design efficient Rome contracts.

Budget Overview

Mode
Max CU
Notes

Atomic (VmAt)

~1,400,000 CU

Single Solana transaction

Iterative (VmIt)

Unlimited (multi-tx)

~500 opcodes per iteration step

Each Solana transaction has a default budget of 200,000 CU, extendable to ~1.4M CU via compute budget instructions (added automatically by the Rome SDK).

CU Cost Estimates

EVM Operations

Operation
Approximate CU
Notes

Signature verification (ecrecover)

~5,000 CU

secp256k1 via Solana syscall

Simple transfer

~50,000-100,000 CU

Balance updates only

ERC-20 transfer

~100,000-150,000 CU

Includes SPL precompile call

Contract deployment (small)

~200,000-400,000 CU

Depends on bytecode size

Storage write (SSTORE)

~5,000-20,000 CU

Cold vs warm access

CPI Operations

Operation
Approximate CU
Notes

Transfer hook base overhead

100,000 CU

Per transfer

Native sub-hook

50,000 CU

Per native Solana hook

EVM sub-hook

200,000 CU

Per EVM hook

Recommended EVM transfer with hooks

800,000 CU

Safe budget for hooked transfers

Precompile Operations

Precompile
Approximate CU

ecrecover

~3,000-5,000 CU

SHA-256

~1,000 CU

BN254 ecAdd

~10,000 CU

BN254 ecMul

~40,000 CU

BN254 ecPairing

~200,000+ CU

Optimization Techniques

1. Use Yul for Hot Paths

Solidity's optimizer produces reasonable code, but Yul (inline assembly) can reduce CU significantly for critical operations:

2. Cache PDA Derivations

PDA derivation via find_program_address is expensive. Store derived PDAs in contract storage rather than computing them on every call:

3. Hardcode Known Program IDs

Don't load program IDs from storage — use constants:

4. Minimize Account Count

Each account in a Solana transaction adds CU overhead. Reduce the number of accounts by:

  • Batching operations that share accounts

  • Using fewer intermediate accounts

  • Avoiding redundant ATA creation checks

5. Use Optimizer Settings

Measuring CU Consumption

Use eth_estimateGas to measure CU before submitting:

Or via ethers.js:

What's Next

Last updated

Was this helpful?