1 min read

Stark/Cairo Tutorial 1-Hello World

Stark/Cairo is a bit obtuse, but you can get to a hello world equivalent by creating hello_world.cairo file with the following:

%builtins output

from starkware.cairo.common.serialize import serialize_word

func main{output_ptr : felt*}():
    serialize_word(99)
    return ()
end

Compile and run the file

cairo-compile hello_world.cairo \
--output hello_world_compiled.json

cairo-run --program=hello_world_compiled.json \
--print_output --layout=small

Program output:
  99

The explanations for this code are found here.

Github for the above here.