# Week 17 at BlocfuseLab: Diving into StarkNet & Cairo Programming This week at BlocfuseLab, we started the StarkNet Masterclass, exploring the Cairo programming language, the backbone of provable programs on StarkNet. Coming from a more traditional web3 development stack, this was a deep dive into something quite different: zero-knowledge proofs and how they can power decentralized applications efficiently. Here’s a breakdown of the key things we learnt this week πŸ‘‡πŸ½ ## Why Cairo? Cairo is a programming language developed for writing provable programs, specifically designed to work with StarkNet, a ZK-rollup scaling solution for Ethereum. The cool thing? You can write programs without needing to deeply understand ZK proofs, Cairo takes care of that for you. ### Benefits: ** No need to deeply understand zk proofs. ** Highly efficient for scalable L2 solutions. ** Offers native support for StarkNet development. ## πŸ”§ Setting Up Our Environment We started by installing Cairo and setting up our local dev environment using the instructions from the official Cairo book. And we wrote our first Cairo program! ![D5E666CB-8FCB-49BF-825B-F8AE32CEAE0F](https://hackmd.io/_uploads/ryJdUW4gge.jpg) ```cairo fn main() {} ``` In Cairo, a valid file must include a main function. Even if the program does nothing, main must be present. ## Variables & Destructuring We learned how to declare and use variables, and even destructure tuples! This is useful when you're working with multiple values bundled together. ![5A3F8B2E-76DE-4086-ADC0-D10086D53DC2](https://hackmd.io/_uploads/BJYAL-4xex.jpg) **Example: Destructuring in Cairo** ![0DE67C25-29E0-4839-A8ED-A1978F208D4E](https://hackmd.io/_uploads/rkmWDbEeel.jpg) ## Operations Cairo supports standard arithmetic operations. Here’s a simple function that adds two numbers: ```cairo fn add(a: felt, b: felt) -> felt { return a + b; } #You can then call this function(add) from main: fn main() { let result = add(10, 5); assert result == 15; return (); } ``` ## Functions and Loops We wrote reusable functions and experimented with basic loop **Function Example:** ```cairo fn multiply(x: felt, y: felt) -> felt { return x * y; } ``` ## Tasks for the Week βœ… Set up Cairo on our devices βœ… Chapter 1–2 of the Cairo Book -> (https://book.cairo-lang.org/ch01-02-hello-world.html) βœ… Wrote simple programs using functions, variables, and loops ## Next Steps We’ll continue with the Cairo Book and dive into more advanced topics such as: *Enums *Interacting with contracts ## Final Thoughts Can’t wait to start writing smart contracts in Cairo and building cool stuff on StarkNet!