110 releases (52 stable)
Uses new Rust 2024
| new 2.15.0 | Dec 19, 2025 |
|---|---|
| 2.14.1-dev.0 | Nov 25, 2025 |
| 2.12.0-rc.3 | Jul 28, 2025 |
| 2.12.0-dev.0 | Mar 25, 2025 |
| 0.1.0 | Jan 4, 2023 |
#166 in Magic Beans
68,100 downloads per month
Used in 22 crates
(11 directly)
4.5MB
71K
SLoC
Compiling and running cairo files
cargo run --bin cairo-run -- --single-file /path/to/file.cairo
If we want to run code that is gas tested:
cargo run --bin cairo-run -- --single-file /path/to/file.cairo --available-gas 200
We currently only run the main function with no arguments besides implicits.
Example
// Calculates fib...
fn main() -> u128 {
fib(1_u128, 1_u128, 100_u128)
}
fn fib(a: u128, b: u128, n: u128) -> u128 {
if n == 0 {
a
} else {
fib(b, a + b, n - 1_u128)
}
}
Command-Line Options
--single-file- Treat the path as a single file instead of a project directory.--available-gas <amount>- Set the amount of gas available for execution.--print-full-memory- Print the full memory state after execution.--allow-warnings- Allow the compilation to succeed even with warnings.--run-profiler- Run the profiler and display profiling information.
Additional Information
- When compiling with --available-gas, if there are cycles in the code, calls to
withdraw_gas_allwill be automatically added. - Functions with calls to
withdraw_gas_allwill not compile without--available-gasvalue. - Functions without calls to
withdraw_gas_allwill not compile with--available-gasvalue. - When running functions returning arrays
--print-full-memoryshould probably be used, to actually see the values contained in the array.
Dependencies
~38–54MB
~802K SLoC