cairo-lang-runner

Crates.iocairo-lang-runner
lib.rscairo-lang-runner
version2.9.0-dev.0
sourcesrc
created_at2023-01-04 07:44:54.403145
updated_at2024-10-20 19:04:51.006893
descriptionBasic cairo runner.
homepage
repositoryhttps://github.com/starkware-libs/cairo/
max_upload_size
id750723
size307,541
(orizi)

documentation

README

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.
Commit count: 5919

cargo fmt