Testing Cairo with Python
Cairo lang ships with support for writing tests in Python. I think it’s in many ways superior to the other ways of testing Cairo code. In this post, I share some testing tips and techniques I hope others find useful as well.pytestSince the Cairo lang modules are in Python we can use pytest to write out tests. I absolutely love pytest - it's, by far, the best testing framework I came across in any language. If you’re new to it, spend some time reading through the documentation, it will de...
Testing Cairo with Python
Cairo lang ships with support for writing tests in Python. I think it’s in many ways superior to the other ways of testing Cairo code. In this post, I share some testing tips and techniques I hope others find useful as well.pytestSince the Cairo lang modules are in Python we can use pytest to write out tests. I absolutely love pytest - it's, by far, the best testing framework I came across in any language. If you’re new to it, spend some time reading through the documentation, it will de...

Mixins
Cairo isn’t an object oriented language, yet we can still have mixins. Essentially, it’s possible to do the equivalent of Solidity’s is Ownable in Cairo. All that’s necessary is to explicitly import all the public functions you want to have in your contract. To illustrate, in the “mixin” file, we define an external function:// // ownable_external.cairo // from ownable.library import Ownable @external func transfer_ownership{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( new...

Mixins
Cairo isn’t an object oriented language, yet we can still have mixins. Essentially, it’s possible to do the equivalent of Solidity’s is Ownable in Cairo. All that’s necessary is to explicitly import all the public functions you want to have in your contract. To illustrate, in the “mixin” file, we define an external function:// // ownable_external.cairo // from ownable.library import Ownable @external func transfer_ownership{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( new...

Cairo conventions
Cairo is a young language so best practices and conventions are still evolving. While building Aura, we created our own to streamline cooperation. You can now find them on GitHub. Keep in mind they are very opinionated, there’s no “right” way. This is what works for us. A huge thank you to bllu and tserg for their contributions ❤️ Other members of the community came up with their conventions. Here are those I know of:Only Dust StarkNet development guidelinesCairo Starknet contracts - Simple c...

Cairo conventions
Cairo is a young language so best practices and conventions are still evolving. While building Aura, we created our own to streamline cooperation. You can now find them on GitHub. Keep in mind they are very opinionated, there’s no “right” way. This is what works for us. A huge thank you to bllu and tserg for their contributions ❤️ Other members of the community came up with their conventions. Here are those I know of:Only Dust StarkNet development guidelinesCairo Starknet contracts - Simple c...
Cairo format GitHub Action
I have a strong opinion that every new programming language should ship with a standard code formatter. Golang does. Rust does. And yes, Cairo does as well 💪 The beauty of a code formatter is that it produces code that everyone hates equally. More importantly, it removes the all-so-tiresome comments about missing a space here or a newline there during code reviews. It was pretty easy to set up a CI action that runs cairo-format on your repo, but now it’s got even easier. I’ve just released c...
Cairo format GitHub Action
I have a strong opinion that every new programming language should ship with a standard code formatter. Golang does. Rust does. And yes, Cairo does as well 💪 The beauty of a code formatter is that it produces code that everyone hates equally. More importantly, it removes the all-so-tiresome comments about missing a space here or a newline there during code reviews. It was pretty easy to set up a CI action that runs cairo-format on your repo, but now it’s got even easier. I’ve just released c...

A glimpse of Cairo 1.0
I couldn't attend StarknetCC, so instead I binge-watched all the talks. The one that got me excited the most is Shahar Papini introducing the vision for Cairo 1.0. The highlights are summarized in these two slides:Cairo 1.0 - The planCairo 1.0 - GoalsYeah, Cairo 1.0 is going to be infinitely more pleasant to use than Cairo 0.x and it's going to be out sooner than you can verify a STARK proof by hand. Listen to the whole talk to get all the details. Besides the improvements to the la...

A glimpse of Cairo 1.0
I couldn't attend StarknetCC, so instead I binge-watched all the talks. The one that got me excited the most is Shahar Papini introducing the vision for Cairo 1.0. The highlights are summarized in these two slides:Cairo 1.0 - The planCairo 1.0 - GoalsYeah, Cairo 1.0 is going to be infinitely more pleasant to use than Cairo 0.x and it's going to be out sooner than you can verify a STARK proof by hand. Listen to the whole talk to get all the details. Besides the improvements to the la...