89 releases (44 stable)

new 2.12.0-dev.1 Apr 23, 2025
2.12.0-dev.0 Mar 25, 2025
2.11.4 Apr 8, 2025
2.10.1 Feb 19, 2025
0.1.0 Jan 4, 2023

#16 in #stark-net

Download history 6108/week @ 2025-01-01 10077/week @ 2025-01-08 7607/week @ 2025-01-15 8566/week @ 2025-01-22 8442/week @ 2025-01-29 7107/week @ 2025-02-05 7734/week @ 2025-02-12 10835/week @ 2025-02-19 11723/week @ 2025-02-26 9624/week @ 2025-03-05 10953/week @ 2025-03-12 7699/week @ 2025-03-19 9085/week @ 2025-03-26 7000/week @ 2025-04-02 10468/week @ 2025-04-09 16393/week @ 2025-04-16

44,351 downloads per month
Used in 16 crates (8 directly)

Custom license

4.5MB
67K 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–40MB
~659K SLoC