Fourier¶
A Rust-flavored DSL for writing WaveLedger smart contracts. Source files end in .fou; the compiler (fourier/compiler.py) lexes, parses, and emits stack-VM bytecode that runs on the WaveLedger VM.
Built on NIST PQC standards. Contracts get native access to the current post-quantum primitives — ML-DSA-87 (FIPS 204) signature verification, SHA3 (FIPS 202) hashing, and SLH-DSA-SHA2-128s (FIPS 205) as an alternate signature scheme — via precompiles at reserved low addresses. No bytecode-level implementation of PQC needed.
Agile by design. New signature schemes are added through a runtime registry: verify_sig(scheme_id, pk, msg, sig) dispatches by ID, so a contract can opt into any registered scheme without recompilation. As NIST standardizes additional PQC primitives, they plug in as new precompile addresses and new registry entries — no Fourier syntax change, no hard fork. See Crypto agility on the WaveLedger docs for the chain-level details.
Deploy from your own code. The official chain SDK (waveledger-sdk on PyPI + npm) compiles, deploys, and calls Fourier contracts programmatically via the playground API — no manual hex packing required.
One source file, one contract. One parser pass, one codegen pass. Every storage slot is explicit. Every call semantic is explicit. Selectors are one byte. Floats and inheritance are intentionally absent in v1.
Quick reference Browse the language
What's in these docs¶
-
Language
Every keyword, every statement, every expression form. Grounded in
fourier/parser.pyandfourier/codegen.py. -
Standard library
Six shipped contracts: ownable, pausable, reentrancy guard, multisig (PQC), timelock, crypto registry. Plus
safe_*arithmetic builtins. -
ABI and calldata
Calldata is a 1-byte selector followed by 32-byte words. No Solidity function-ID hash. No variable-length args in v1 (except
bytesreturns). -
Compiler
compile_source(text) -> bytes. That's the API. No CLI in v1 — use the Python entry directly or wrap it yourself. -
Examples
Counter, ERC-20-style token, and walkthroughs of the two canonical
.foufiles shipped in the repo. -
VM internals
Every opcode, every gas cost, every precompile address. The VM is in
vm/— these docs mirror that source.
Five-minute orientation¶
| Property | Value |
|---|---|
| Source extension | .fou |
| Compiler entry | fourier.compile_source(source: str) -> bytes |
| Target | WaveLedger stack VM (256-bit words) |
| Selector width | 1 byte (0x01 for the first pub fn, incrementing) |
| Calldata layout | [selector:1][arg0:32][arg1:32]... |
| Storage slot width | 256 bits |
| Mapping key derivation | SHA3-256(key_word || slot_word) |
| Init guard slot | 2**256 - 1 (reserved; collides → compile error) |
| Local memory base | 0x80 |
| Return memory slot | 0x40..0x60 |
| Reserved keywords | contract storage event fn pub let if else while return emit map array struct true false uint address bool bytes |
| Builtins | caller callvalue origin block_height timestamp balance sha3 safe_add safe_sub safe_mul safe_div pack_sel call_b delegatecall_b staticcall_b verify_sig call len push pop |
| Precompile addresses | 0x01 SHA3-512, 0x02 ML-DSA-87 verify, 0x03 SLH-DSA-SHA2-128s verify |
What Fourier is not (v1)¶
- No inheritance, traits, or interfaces. Copy declarations from stdlib contracts into your contract, or call them via address.
- No IEEE 754 floating point. Use the Q64.64 fixed-point builtins (
from_int,to_int,fmul,fdiv) — see expressions / fixed-point math.
Supported as of v1:
- String literals (
"hello") — desugar to a right-paddeduint. See types. initconstructor parameters — unpacked from the deploy tx'sinit_calldata. See contracts.library Foo { ... }blocks plusFoo::method(addr, gas, args...)call syntax — declarative library interfaces compiled to DELEGATECALL. See cross-contract / library blocks.lib_call— lower-level DELEGATECALL builtin that thelibrarysyntax desugars to. Useful when you don't want to declare the interface up front. See cross-contract / lib_call.- Multi-contract source files — a
.foumay declare multiplecontractblocks. Usecompile_source_all(src)for all bytecodes orcompile_source(src, name="...")for one. See compiler / Python API. - Fixed-point math (Q64.64) —
from_int,to_int,fmul,fdivbuiltins for scaled decimal arithmetic on plainuintvalues. See expressions. - Peephole optimizer — runs by default. Current folds eliminate trivial
PUSH/POPand identity-arithmetic patterns. Runpython3 scripts/bench_fourier.pyto measure on your contracts.