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

Download history 9403/week @ 2025-08-27 9795/week @ 2025-09-03 14340/week @ 2025-09-10 8406/week @ 2025-09-17 8884/week @ 2025-09-24 6599/week @ 2025-10-01 8405/week @ 2025-10-08 12360/week @ 2025-10-15 15459/week @ 2025-10-22 17271/week @ 2025-10-29 13302/week @ 2025-11-05 11393/week @ 2025-11-12 16013/week @ 2025-11-19 15897/week @ 2025-11-26 16951/week @ 2025-12-03 17307/week @ 2025-12-10

68,100 downloads per month
Used in 22 crates (11 directly)

Custom license

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_all will be automatically added.
  • Functions with calls to withdraw_gas_all will not compile without --available-gas value.
  • Functions without calls to withdraw_gas_all will not compile with --available-gas value.
  • When running functions returning arrays --print-full-memory should probably be used, to actually see the values contained in the array.

Dependencies

~38–54MB
~802K SLoC