Cairo by example

Cairo is a programming language that can be used to write blockchain applications. The language is novel in that it converts program logic into STARK proofs.

First setup using Nile which makes managing files and command line calls to StarkNet simple. Second have a look at how pytest works After you have set everything up, to run the examples:

  • Open two terminals in the project folder and run source env/bin/activate
  • In one run nile node to start a local devnet.
  • In the other run the commands in the examples.

Examples of different elements in Cairo and StarkNet.

  • Hello, World!
  • First application
  • Array
  • Data types
  • Variables
  • Read and write values
  • Read and write tuples
  • Currency
  • Constructor
  • Custom imports
  • Contract calls
  • Array argument
  • Array returns
  • Struct returns