87 releases (43 stable)

2.12.0-dev.0 Mar 25, 2025
2.10.1 Feb 19, 2025
2.10.0-rc.0 Dec 22, 2024
2.9.1 Nov 29, 2024
0.1.0 Jan 4, 2023

#19 in #smart-contracts

Download history 7201/week @ 2024-12-17 5149/week @ 2024-12-24 6014/week @ 2024-12-31 9120/week @ 2025-01-07 8042/week @ 2025-01-14 8025/week @ 2025-01-21 9098/week @ 2025-01-28 6839/week @ 2025-02-04 8150/week @ 2025-02-11 10274/week @ 2025-02-18 11770/week @ 2025-02-25 9416/week @ 2025-03-04 11019/week @ 2025-03-11 8130/week @ 2025-03-18 8758/week @ 2025-03-25 6001/week @ 2025-04-01

35,655 downloads per month
Used in 16 crates (8 directly)

Custom license

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

~29–39MB
~649K SLoC