60 releases (26 stable)

2.6.3 Mar 12, 2024
2.6.0-rc.1 Feb 14, 2024
2.5.0-dev.0 Dec 26, 2023
2.4.0-rc6 Nov 26, 2023
0.1.0 Jan 4, 2023

#1258 in Magic Beans

Download history 4440/week @ 2023-12-23 4408/week @ 2023-12-30 4808/week @ 2024-01-06 5369/week @ 2024-01-13 5796/week @ 2024-01-20 5687/week @ 2024-01-27 7485/week @ 2024-02-03 6895/week @ 2024-02-10 6299/week @ 2024-02-17 4957/week @ 2024-02-24 6095/week @ 2024-03-02 6287/week @ 2024-03-09 6032/week @ 2024-03-16 6301/week @ 2024-03-23 4872/week @ 2024-03-30 6980/week @ 2024-04-06

24,639 downloads per month
Used in 12 crates (5 directly)

Custom license

3.5MB
52K 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

~22–34MB
~521K SLoC