What’s new in Cairo?

There have been a lot of changes since the Cairo language has been released. This is a developer opinionated list of the major changes since the first release, 0.6.2 (Dec 2021).

StarkWareLtd last release CairoLang v0.10.3 (Dec 5, 2022) also named Cairo 1.0.

Useful links:

v0.10. (Cairo 1.0)

(breaking changes version) Dec. 5 2022 v0.10.0-pre Pre-release

Starknet has its core language modified, it’s now a Rusty lang, Starknet foresaw the future of Rust based smart-contract ecosystem (Luna developers and Solana)

  • End statements with ;

    • Note that new lines are still part of the language at this point, and you cannot put more than one instruction per line. This will change in Cairo1.0.
  • Use { … } for code blocks (instead of : and end)

  • Add () around the condition of if statements

  • Remove the member keyword in structs

  • Change comment to use // instead of #

  • Use …, ap++ instead of …; ap++ in low level Cairo code

  • New transaction version

    • Nonce are enforced as part of the transaction (bye bye UTXO model)
    • Invoke execution object with __validate__ and __execute__ to differentiate between validation of the transaction (wether or not execution works (TODO: wild guess)) and execution that his pickup by another part of the process in the decentralized system(TODO: confirm)
    • Declare function to send implementation code for registration for future instantiation
  • Bridge Layer1 to Layer2

  • Tx simulation and fee estimation

  • Support the EC-op builtin. to allows to verify ECDSA signatures

  • API: Remove entry_point_type field from transaction information

v0.9.x

Fees are now enforced on StarkNet, no more free candy!

Contracts must be declared first and then instanciated through the new deploy syscall forcing 2 manual transactions for contracts deployed by EOA.

v0.8.1

Fees are in now! What’s up with that code ? See more here.

  • charge_fee

  • calculate_tx_fee_by_cairo_usage

  • L1 -> L2 message cancellation

  • version and max_fee are part of the transaction structure now

  • __execute__ is now required mandatory entry point for account contract, see more here

  • Added the cryptographic hash function blake2s to the standard library

Cairo

  • Meaningful error messaging(v0.7.0) including local variables and arguments

  • High level memory allocation with the new keyword in execution memory segment (whereas alloc allocates a new memory segment)

  • Tuples and type aliases, will increase the pythonic vibes of Cairo even further

  • Fix for python 3.9

v0.7.x

Addition of EVM compatibilities

  • events are here !

(editor’s note: TheGraph but for StarkNet please.)

  • delegate calls prepend delegate_ to external contract function name or l1_handler
  • The __default__ entry point is introduced, it is similar to the Solidity fallback method as it is executed after missing on the function selector.
  • The __l1_default__ entry point same as __default__ but for in-protocol message from the L1.

New syscalls

  • get_block_timestamp() Returns a random number that sometimes appears to grow over time, currently around since 1970-01-01. Notice of deprecation for get_tx_signature(), get_tx_info() is now preferred.