Stop Guessing Smart Contract Costs.
Empirical Budget Assertions for Soroban.
Local Soroban resource estimates do not match real network costs. In empirical testnet benchmarks, local Rust estimates ran ~81% under actual costs, while WASM-mode estimates swung from ~8% under to ~19% over.
soroban-budget-assert provides empirical budget certainty before on-chain execution.
The Cost-Gap Problem
Real measured figures comparing local estimates against Soroban Testnet ground truth for do_expensive_work(10_000).
Native Rust test execution (no WASM). Unreliable for budget decisions.
Compiled with Cargo's default release profile (opt-level=3).
Compiled with size optimization (opt-level="z", LTO enabled).
Actual CPU instructions returned by simulateTransaction on testnet.
Two-Tier Defense System
Combine fast local test assertion gates with network-verified workspace reporting.
budget-macros
Rust attribute macros (#[budget_cpu_lt(N)], #[budget_mem_lt(N)]) applied directly to your test functions.
- Fails
cargo testthe moment cost crosses pinned limit - Catches cost regressions locally in CI before deploying
- Reads
env.cost_estimate().budget()automatically
cargo-budget-report
A CLI tool that discovers contracts, compiles WASM, and simulates execution against Soroban Testnet.
- Automatically discovers all contracts in your workspace
- Simulates execution on Testnet via
simulateTransaction - Reports execution resources (CPU instructions, read/write bytes)
- Configurable via central
budget.toml
Quick Start
Get up and running in under a minute.
# Install cargo-budget-report from repository root
cargo install --path cargo-budget-report
# Run report across workspace
cargo budget-report
network = "testnet"
source = "alice"
[functions.do_expensive_work]
args = ["--n", "10000"]
use budget_macros::{budget_cpu_lt, budget_mem_lt};
use soroban_sdk::Env;
#[test]
#[budget_cpu_lt(950000)] // Fails test if CPU instruction budget exceeds limit
fn test_cpu_budget() {
let env = Env::default();
let wasm = std::fs::read("../target/wasm32v1-none/release/my_contract.wasm")
.expect("build the WASM first");
let contract_id = env.register_contract_wasm(None, wasm.as_slice());
let client = MyContractClient::new(&env, &contract_id);
env.cost_estimate().budget().reset_unlimited();
client.do_expensive_work(&10_000);
}
See It in Action
Watch cargo budget-report simulate and report execution resources across workspace contracts.
Having trouble viewing the embedded demo? Watch the terminal recording on Asciinema.