Philipp Muens | pmuens.eth
Philipp Muens | pmuens.eth

Philipp Muens | pmuens.eth

Cairo by Example

Photo by Simon Berger on Unsplash

Cairo by Example

Learn Cairo and StarkNet Smart Contract programming with example code

Philipp Muens | pmuens.eth's photo
Philipp Muens | pmuens.eth
ยทSep 20, 2022ยท

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Today I'm happy to announce the launch of my side-project "Cairo by Example" that I've been working on throughout the last couple of weeks.

Cairo by Example is a resource hub with explanations, code snippets and mini examples to help others learn the Cairo Programming Language and get onboarded to the StarkNet ecosystem.

It also acts as a reference developers can use whenever they need to refresh their knowledge about topics such as registers or L1 to L2 and L2 to L1 communication.

What is Cairo?

So why should you care about Cairo?

Cairo is one of the few programming languages that's turing complete as well as provable. Once you wrote your Cairo program you can take it to a "Prover" which will generate a proof that attests to the validity the program execution.

The proof can then be taken to a "Verifier" which checks its validity.

It's important to note that while the proof can be more involved and resource intensive, validations are cheap to run in comparison.

After reading all this one might be thinking: "So what's the big deal with having provable programs?"

What is StarkNet?

Having provable programs means that one can run the program anywhere while still attesting to the correct execution of it.

This comes in handy when you want to scale Blockchains. Rather than having all the Nodes within the Blockchain Network run the same computation one can run the computation off-chain, create a proof for it and validate it on-chain.

This is exactly what StarkWare implemented via StarkNet to scale Ethereum.

StarkNet Smart Contracts are written in Cairo and their execution is done off-chain. A prover that's also running off-chain generates proofs that the StarkNet Smart Contract execution was done correctly. Those proofs are then sent to a Verifier Smart Contract that's implemented as an Ethereum Smart Contract and checks the proofs validity on-chain.

If you have this kind of architecture which is called an L2 or more specifically a ZK-Rollup you can scale Ethereum's throughput and data processing capabilities while still inheriting it's security in your L2.

Conclusion

I hope this Blog Post got you excited about the possibilities ZK-Rollups and StarkNet in particular offer. To jump straight into StarkNet Smart Contract programming you should get yourself familiar with the Cairo Programming Language.

While I got my feet wet I decided to create a learning- and reference resource in the form of the "Cairo by Example" project. I hope that it helps you throughout your learning- and Smart Contract authoring journey!

Additional Resources

ย 
Share this