77 releases (36 stable)

new 2.9.2 Dec 11, 2024
2.9.1 Nov 29, 2024
2.9.0-dev.0 Oct 20, 2024
2.7.0-rc.3 Jul 16, 2024
0.1.0 Jan 4, 2023

#40 in Magic Beans

Download history 4019/week @ 2024-08-23 4785/week @ 2024-08-30 4317/week @ 2024-09-06 7588/week @ 2024-09-13 6200/week @ 2024-09-20 4499/week @ 2024-09-27 6909/week @ 2024-10-04 5481/week @ 2024-10-11 3508/week @ 2024-10-18 5023/week @ 2024-10-25 6094/week @ 2024-11-01 6434/week @ 2024-11-08 3968/week @ 2024-11-15 3882/week @ 2024-11-22 10826/week @ 2024-11-29 13457/week @ 2024-12-06

33,877 downloads per month
Used in 14 crates (7 directly)

Custom license

4.5MB
57K 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

~28–39MB
~639K SLoC