
The Solana Token 2022 Specification
The Solana Token 2022 Specification Token-2022 is a new backward-compatible version of the SPL Token program that supports additional features in the form of extensions. The bytecode for these extensions…

Time Travel Testing with LiteSVM
Time Travel Testing with LiteSVM In Solana, writing test cases that depend on the passing of time is tricky. We might want to test that something happens in our code…

Implementing Token Metadata with Metaplex
Implementing Token Metadata with Metaplex We introduced the Metaplex metadata standard in the previous tutorial. In this one, we’ll create an SPL token and attach metadata to it using the…

How Metaplex Metadata for Tokens Works
How Metaplex Metadata for Tokens Works We have deployed and interacted with SPL tokens, but none of them had a name, symbol, or any metadata attached. Instead, we identified each…

Basic Bank Tutorial
Basic Bank Tutorial with SPL Tokens and Anchor In this tutorial, we’ll build a simple bank program on Solana with the basic features you’d expect from a regular bank. Users…

Token Sale with Total Supply Tutorial
Token Sale with Total Supply Tutorial A token sale program is a smart contract that sells a specific token, usually in exchange for a native token like SOL, at a…

Transferring SPL Tokens with Anchor and Web3.js
Transferring SPL Tokens with Anchor and Web3.js In the previous tutorial, we learned how SPL tokens work. In this tutorial, we’ll implement a full SPL token lifecycle: create, mint, transfer,…

How the SPL Token Works
How the SPL Token Works Solana Program Library Token (SPL Token) is Solana’s standard for tokens: how to create tokens and how they should behave. It is Solana’s equivalent to…

Calculating the real reserves between two prices in the Uniswap V3 codebase
Calculating the real reserves between two prices in the Uniswap V3 codebase In previous chapters, we derived formulas to calculate the real reserves of tokens X and Y between two…

The Fundamental Theorem of Finite Cyclic Groups
The Fundamental Theorem of Finite Cyclic Groups The Fundamental Theorem of Cyclic Groups provides guarantees about the existence of cyclic subgroups within a cyclic group. In the context of the…

The constant product formula in Uniswap v3
The constant product formula in Uniswap v3 Our goal is to derive the constant product formula based on real reserves for a segment, given by $$ L^2 = (x_r+\frac{L}{\sqrt{p_u}})(y_r+L\sqrt{p_l})$$ and…

How Ethereum address are derived (EOAs, CREATE, and CREATE2)
How Ethereum address are derived (EOAs, CREATE, and CREATE2) On Ethereum, smart contracts can be deployed in one of three ways: An Externally Owned Account (EOA) initiates the transaction where…

Real reserves in Uniswap v3
Real reserves in Uniswap v3 In the last chapter, we introduced two new concepts: real reserves and virtual reserves. The real reserves of a segment are the amount of tokens…

Real and virtual reserves in Uniswap v3
Real and virtual reserves in Uniswap v3 Uniswap v3 uses two types of reserves: real reserves and virtual reserves. Real reserves represent the actual amount of tokens present in a…

ERC-6551 Standard: Token Bound Accounts (TBA)
ERC-6551 Standard: Token Bound Accounts (TBA) Introduction NFTs were originally created to represent ownership of digital or physical assets, like collectibles. However, they were limited to tracking ownership of an…

Tickmath getSqrtRatioAtTick
Tickmath getSqrtRatioAtTick This article explains how the getSqrtRatioAtTick() function in Uniswap V3 TickMath library works. The getSqrtRatioAtTick() function takes a tick index and returns the square root price at that…

Public and Private Inputs
Public and Private Inputs A public input in Circom is a signal in the witness that will be revealed to the verifier. For example, suppose we want to create a…

Circle FFT — Part 1: Building the Circle Domain
Circle FFT — Part 1: Building the Circle Domain Circle STARKs is a new zk-STARK scheme that has been implemented in Stwo and Plonky3, and it has been adopted by several zkVM projects. Its…

Square and Multiply Algorithm
Square and Multiply Algorithm The square and multiply algorithm computes integer exponents in $\mathcal{O}(\log n)$ (logarithmic time). The naive way to compute an exponent $x^n$ is to multiply $x$ by…

Uniswap V2 Architecture: An Introduction to Automated Market Makers
Uniswap V2 Architecture: An Introduction to Automated Market Makers Uniswap is a DeFi app that enables traders to swap one token for another in a trustless manner. It was one…

Multiplicative Subgroups and Primitive Elements
Multiplicative Subgroups and Primitive Elements Introduction This chapter continues our study of group theory by exploring subgroups and generators. The concept of a primitive element will be introduced at the…

Computing the Current Tick Given sqrtPriceX96
Computing the Current Tick Given sqrtPriceX96 In the previous chapters, we saw that the protocol stores the square root of the price instead of the price itself. Therefore, it is…

Uniswap V3 Factory and the Relationship Between Tick Spacing and Fees
Uniswap V3 Factory and the Relationship Between Tick Spacing and Fees In early chapters, we introduced the concept of ticks, which discretize the price curve. A tick is a price…

ZK Proof of Selection Sort
ZK Proof of Selection Sort Most computations of interest are generally “stateful” — that is, they need to go through a series of steps to produce the final result. Sometimes,…

How a ZKVM Works
How a ZKVM Works A Zero-Knowledge Virtual Machine (ZKVM) is a virtual machine that can create a ZK-proof that verifies it executed a set of machine instructions correctly. This allows…

The Permutation Argument
The Permutation Argument A permutation argument is a proof that two lists hold the same elements, but possibly in a different order. For example, [2,3,1] is a permutation of [1,2,3]…

ZK Friendly Hash Functions
ZK Friendly Hash Functions ZK-friendly hash functions are hash functions that require much fewer constraints to prove and verify than traditional cryptographic hash functions. Hash functions such as SHA256 or…