Home
Cairopractice
Cancel

Building a fully onchain NFT

Let’s build a fully onchain NFT. It will look something like this: To achieve this, there are three standards we need to stitch together - Data URI, Opensea Metadata Standard and SVG. We’ll have...

The inherent security of Starknet

When building blockchain applications, security is paramount, regardless what some fools say. Thankfully, many factors of how Starknet is designed and built contribute to it being the safest blockc...

Understanding upgradability

Starknet gives us, developers, the power to make our contracts upgradable in a native way. Unlike in the EVM world where one has to fiddle with the inferior proxy pattern, in Starknet we can utiliz...

Starknet fee reduction

Multiple factors go into calculating transaction fees on Starknet. The biggest one - use of storage - is going to be addressed by 4844 in a couple of days and by additional measures later this year...

When is get_caller_address zero?

It’s very rare for the caller address (as obtained by get_caller_address()) to be zero on Starknet. Let’s examine when can this happen. The obvious case is when calling a view function. The call i...

Compact module declaration

Here’s a cool technique how to declare all of a project’s modules inside the project root (typically src/lib.cairo) without any intermediary module files. Let’s say we have a project where src/ lo...

Underhanded Cairo, pt. 2. Solution

The results are in. Congratulations to wong_ssh and 0xkaliber, the only two participants who found the attack. Job well done guys! Thank you as well to all the others who gave it a try 🙏 So what’s ...

Underhanded Cairo, pt. 2. Intro

As promised on Twitter, here’s the vulerable contract. It’s a proof of concept, but I tried to make it so that it resembles an actual contract, so there’s more than just the bare minimum for a PoC...

Store packing

One of my favorite recent additions to Cairo is the StorePacking trait: trait StorePacking<T, PackedT> { fn pack(value: T) -> PackedT; fn unpack(value: PackedT) -> T; } A sup...

Using libfuncs

You know how felt division is “disabled” by default in Cairo 1? But what if we really know what we’re doing and are not afraid of shooting ourselves in the foot? It’s actually quite easy to bring i...