cairo by example


In Cairo programs, any text after a pair of forward slashes (//) and until the end of the line will be ignored by the compiler.

You can use this to leave explanatory comments in your code.

fn main() -> felt252 {
    // start of the function
    1 + 4 // return the sum of 1 and 4

Try it out!
  1. Install the toolchain:
    • For macOS and Linux, run our script:
    • curl -sL | bash -s 2.2.0
    • For Windows and others, please see the official guide
  2. Run the example:
    1. Copy the example into a comments.cairo file and run with:
    2. %!s(<nil>) comments.cairo

prev (structs) next (zeroable)