86 releases (43 stable)

2.11.2 Mar 10, 2025
2.10.1 Feb 19, 2025
2.10.0-rc.0 Dec 22, 2024
2.9.1 Nov 29, 2024
0.1.0 Jan 4, 2023

#745 in Magic Beans

Download history 10880/week @ 2024-12-01 13677/week @ 2024-12-08 9516/week @ 2024-12-15 5125/week @ 2024-12-22 5921/week @ 2024-12-29 7042/week @ 2025-01-05 8996/week @ 2025-01-12 8260/week @ 2025-01-19 9363/week @ 2025-01-26 7653/week @ 2025-02-02 6608/week @ 2025-02-09 9257/week @ 2025-02-16 12761/week @ 2025-02-23 9446/week @ 2025-03-02 9961/week @ 2025-03-09 9037/week @ 2025-03-16

41,756 downloads per month
Used in 15 crates (7 directly)

Custom license

4.5MB
65K 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)
    }
}

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

~29–39MB
~656K SLoC