79 releases (36 stable)

new 2.10.0-rc.1 Jan 15, 2025
2.10.0-rc.0 Dec 22, 2024
2.9.1 Nov 29, 2024
2.7.0-rc.3 Jul 16, 2024
0.1.0 Jan 4, 2023

#6 in #gas

Download history 5218/week @ 2024-09-26 6780/week @ 2024-10-03 5563/week @ 2024-10-10 3639/week @ 2024-10-17 4407/week @ 2024-10-24 6710/week @ 2024-10-31 5449/week @ 2024-11-07 4954/week @ 2024-11-14 3686/week @ 2024-11-21 8742/week @ 2024-11-28 14966/week @ 2024-12-05 10010/week @ 2024-12-12 6009/week @ 2024-12-19 5086/week @ 2024-12-26 6119/week @ 2025-01-02 8984/week @ 2025-01-09

27,871 downloads per month
Used in 14 crates (7 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 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

~28–39MB
~633K SLoC