
FFT Friendly Finite Fields
FFT Friendly Finite Fields In order to carry out the FFT algorithm in a finite field (the Number Theoretic Transform), there needs to be $k$-th roots of unity such that…

Components Part 2: OpenZeppelin ERC-20 Tutorial
Components Part 2: OpenZeppelin ERC-20 Tutorial In Component Part 1, we learned how to create and use a component within a single file. We built a CounterComponent from scratch and…

Cairo Components Part 1
Cairo Components Part 1 Components in Cairo behave like abstract contracts in Solidity. They can define and work with storage, events, and functions, but they can’t be deployed on their…

ERC-20 Token on Starknet
ERC-20 Token on Starknet ERC-20 tokens on Starknet work the same way as on Ethereum. In fact, STRK (Starknet’s fee token) is itself an ERC-20 token; there’s no special "native"…

Cheatcodes in Starknet Foundry
Cheatcodes in Starknet Foundry A "cheatcode" in Foundry is a mechanism that allows contract tests to control environment variables such as caller address, the current timestamp, and so on. In…

Events in Starknet
Events in Starknet Events emit data from contract execution into the transaction receipt. The receipt holds metadata about what happened during the execution, which can be queried or indexed by…

Access Control in Cairo
Access Control in Cairo Access control defines who can call specific functions or modify contract behavior. This article explains how Cairo implements access control using the assert macro. A Review…

Constructors in Cairo
Constructors in Cairo A constructor is a one-time-call function executed during contract deployment to initialize state variables, perform contract setup tasks, make cross-contract interactions and so on. In Cairo, constructors…

Type Casting
Type Casting Type casting in Cairo is the process of converting values from one data type to another. This becomes necessary when working with Cairo’s strict type system, where explicit…

Cairo Storage Variable Types
Cairo Storage Variable Types Before a type can be stored in Cairo contract storage, it must implement a trait called the starknet::Store trait. This trait defines how a type is…

Function Visibility in Cairo
Function Visibility in Cairo Cairo does not have "internal" and "pure" modifiers (or any other modifiers for that matter) like Solidity does. Recall that marking an impl block with #[abi(embed_v0)]…

Integers in Cairo
Integers in Cairo Cairo doesn’t offer the full range of integer sizes found in Solidity. While Solidity provides integer types for every multiple of 8 bits up to 256, Cairo…

Structure of a Basic Contract
Structure of a Basic Contract This article shows how to build a deployable Cairo contract for Starknet. Starting from a simple sketch, we will gradually add features to build a…

Cairo for Solidity Developers
Cairo for Solidity Developers Cairo is a Rust-inspired language that compiles to bytecode, which runs on the Cairo Virtual Machine. The Cairo Virtual Machine is a zero-knowledge virtual machine (ZKVM)…

Introduction to the Cairo Language
Introduction to the Cairo Language Cairo is a domain-specific programming language designed for provable, verifiable computation, particularly within the context of zero-knowledge systems like Starknet, a Layer 2 (L2) network…

Positions in Uniswap v3
Positions in Uniswap v3 Adding liquidity to an AMM means depositing tokens into the AMM pool. Liquidity providers do this in the hope of earning fees from users who swap…

NTT Algorithm By Hand
NTT Algorithm By Hand The NTT (Number Theoretic Transform) algorithm converts a polynomial in a finite field from coefficient form to point form. If a polynomial has degree $d$ then…

Roots of Unity raised to the k/2 power equals 1 or -1
Roots of Unity raised to the k/2 power equals 1 or -1 Any $k$-th root of unity with even $k$ raised to the $k/2$ power will result in 1 or…

Evaluating multivalued functions by square root expansion
Evaluating multivalued functions by square root expansion In the previous chapter on Image Preservation of Multivalued Functions we saw that instead of evaluating $f(x)$ on the $k$-th roots of unity,…

The Image Preservation Theorem for Multivalued Functions
The Image Preservation Theorem for Multivalued Functions We’ll start this chapter on an unusual note — the NTT algorithm is quite simple and can be implemented in less than 20…

Square Roots of Roots of Unity
Square Roots of Roots of Unity The square root of a number $x$ is $y$ such that $y^2=x$. When $x$ is of the form $x^m$ and $m$ is even, then…

The square of a k-th root of unity is a k/2-th root of unity
The square of a k-th root of unity is a k/2-th root of unity If we take the set of $k$-th roots of unity (with $k$ even) and square each…

Visual representation of the roots of unity
Visual representation of the roots of unity The property that if $\omega$ is a $k$-th root of unity, then $\omega^i$ and $\omega^{i+k/2}$ are additive inverses may seem a little abstract…

Roots of unity ω have the property ω^(k/2) ≡ −1
Roots of unity ω have the property ω^(k/2) ≡ −1 In previous articles, we established that in the finite field $\mathbb{F}_q$, if $k$ divides $q-1$: There exists a unique subgroup…

Vandermonde Matrices
Vandermonde Matrices A Vandermonde matrix is a matrix that converts a polynomial from its coefficient representation into its value representation at a set of points. For a polynomial $f(x) = a_0 +a_1x + a_2x^2+\dots+a_{k-1}x^{k-1}$ with its…

Roots of Unity in Finite Fields
Roots of Unity in Finite Fields This article explains what Roots of Unity in a Finite Field are and how they are intertwined with multiplicative subgroups. The reader is expected…

Interest Bearing Token Part 2
Interest Bearing Token Part 2The interest-bearing extension adds the ability for a token mint to accrue interest over time. In our previous discussion of Token-2022, we introduced the interest-bearing extension…














