Live from the chain

The discovery stream
Latest digit discovered
7
index  
block  
proof  0x…
verified ✓
3.
Digits found
verify() calls
Unique finders

The loop

From a swap to a proven digit, in one transaction.

π isn’t stored anywhere. Every digit is earned by a trade and derived on the spot — then anyone can recompute it to check our work.

01
swap

You swap

Trade any size on the π pool. It’s an ordinary Uniswap v4 swap — same gas, same routing.

02
hook

The hook fires

v4 routes execution into π’s afterSwap hook before the trade settles.

03
π

A digit is revealed

The next digit of π — committed onchain — is read in sequence and written to state.

04
proven

It’s proven onchain

The digit and its index are committed to state. verify(n) returns it for anyone to check.

Uniswap v4 · the hook

A hook that fishes digits out of π.

v4 hooks let a pool run custom logic at points in a swap’s lifecycle. Ours mines a hook address with the afterSwap permission flag, so every completed trade hands control to the π contract.

Instead of reading a price, it advances a counter and pulls the next digit of π straight from the math. We use the Bailey–Borwein–Plouffe spigot — a formula that yields the n-th digit on its own, so the contract never has to store or recompute the ones before it.

  • Lifecycle pointafterSwap
  • DerivationBBP spigot · base-16
  • State per digitindex · value · proof
  • MemoryO(1) — no table
  • Verificationverify(n) · permissionless
A fishing hook above a spiral well of digits
  PiHook.sol
// fired by the PoolManager after every swap
function afterSwap(...) external onlyPoolManager
    returns (bytes4, int128)
{
    uint256 n = piIndex + 1;
    uint8 digit = PiSpigot.digitAt(n); // BBP
    _commit(n, digit);            // → onchain state
    emit DigitDiscovered(n, digit, sender);
    piIndex = n;
    return (BaseHook.afterSwap.selector, 0);
}