Tier 1 — Prevent
Catch structurally expensive anti-patterns (storage in loops, redundant clones) before your code compiles using rustc and Dylint static analysis.
Cost Linter Docs →
A three-tier cost awareness pipeline for Stellar smart contracts. Lint at compile time, assert at test time, profile when the budget fails — so every CPU instruction and storage byte is accounted for before mainnet.
Select a stage to inspect its role, runtime mechanism, and telemetry output.
warning: storage write inside loop
--> contracts/pool/src/lib.rs:88:9
|
88 | env.storage().instance().set(&key, &val);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: batch storage operations outside the loop
= note: each write incurs 25k CPU instructions and ledger write feesExecute each tier through familiar Cargo subcommands with zero disruption to standard Rust workflows.
A static analysis shield for Soroban smart contracts. Hooks directly into rustc to catch expensive patterns before compilation.
An empirical runtime test harness. Measures network-simulated resource consumption and fails CI when budget limits are breached.
Visual flamegraphs and execution tracing. Diagnoses exactly which functions, loops, and host operations burned your budget.
Inspect how common contract operations translate into protocol-level resource consumption and fees.
Mutating instance or persistent storage on every loop iteration re-serializes entries and consumes non-refundable write fees per cycle.
for item in items.iter() {
// [HAZARD] Incurs N writes and N host cross-calls
env.storage().instance().set(&item.key, &item.val);
}let mut batch = env.storage().instance().get(&BATCH_KEY).unwrap_or(...);
for item in items.iter() {
batch.push_back(item);
}
// [OPTIMAL] Commit once at loop completion
env.storage().instance().set(&BATCH_KEY, &batch);Soroban charges for every hardware resource your contract consumes on-chain under Stellar Protocol 22:
| Resource Dimension | Unit of Measurement | Hard Cap (Per Tx) | Fee Impact |
|---|---|---|---|
| CPU Instructions | Executed instruction count | 100,000,000 instructions | Non-refundable fee per million instructions |
| Memory Allocations | Bytes allocated / resident | 40 MB | Enforced limit (execution fails on breach) |
| Ledger Entry Reads | Key-value pairs accessed | 40 entries | Non-refundable fee per entry read |
| Ledger Entry Writes | Key-value pairs mutated | 25 entries | Non-refundable fee per entry written |
| Ledger Read Bytes | Serialized payload bytes | ~200 KB | Non-refundable fee per KB read |
| Ledger Write Bytes | Serialized payload bytes | ~100 KB | Non-refundable fee per KB written |
| Ledger Space Rent | Byte × Ledgers duration | Dynamic | Dynamic refundable rent based on entry TTL |
Every wasted instruction is a fee your users pay
Cost bugs don't fail standard unit tests — they silently inflate transaction fees in production. Use the Tollcraft pipeline to audit, gate, and diagnose your contracts before deployment.