73 releases (32 stable)

2.9.0-dev.0 Oct 20, 2024
2.8.2 Sep 8, 2024
2.7.0-rc.3 Jul 16, 2024
2.6.3 Mar 12, 2024
0.1.0 Jan 4, 2023

#4 in #stark-net

Download history 3455/week @ 2024-07-18 4996/week @ 2024-07-25 7222/week @ 2024-08-01 6531/week @ 2024-08-08 5133/week @ 2024-08-15 3765/week @ 2024-08-22 4913/week @ 2024-08-29 4392/week @ 2024-09-05 7147/week @ 2024-09-12 6068/week @ 2024-09-19 5218/week @ 2024-09-26 6780/week @ 2024-10-03 5563/week @ 2024-10-10 3639/week @ 2024-10-17 4414/week @ 2024-10-24 6607/week @ 2024-10-31

21,657 downloads per month
Used in 13 crates (6 directly)

Custom license

4.5MB
58K 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 beside 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
~650K SLoC