00_Cairo Program Entry#
The version of the Cairo compiler used in this article is 2.0.0-rc0. Since Cairo is being updated rapidly, there may be slight differences in syntax between different versions. The article will be updated to a stable version in the future.
Entry Point for Single-File Cairo Programs#
Similar to most programming languages, the entry point for a single-file Cairo program is the main function.
To run the program, use the following command:
The main function can have a return value, as shown below:
The return value will be output within square brackets on this line:
Entry Point for Starknet Smart Contracts#
Start with #[starknet::contract], and add the contract name after the mod keyword.