61 releases (26 stable)

2.7.0-dev.0 May 22, 2024
2.6.3 Mar 12, 2024
2.6.0-rc.1 Feb 14, 2024
2.5.0-dev.0 Dec 26, 2023
0.1.0 Jan 4, 2023

#1281 in Magic Beans

Download history 6483/week @ 2024-02-12 6233/week @ 2024-02-19 4737/week @ 2024-02-26 6147/week @ 2024-03-04 6323/week @ 2024-03-11 6167/week @ 2024-03-18 5871/week @ 2024-03-25 5156/week @ 2024-04-01 7115/week @ 2024-04-08 6934/week @ 2024-04-15 4873/week @ 2024-04-22 6642/week @ 2024-04-29 5780/week @ 2024-05-06 4212/week @ 2024-05-13 4935/week @ 2024-05-20 3388/week @ 2024-05-27

19,960 downloads per month
Used in 12 crates (5 directly)

Custom license

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

~25–39MB
~590K SLoC