Quickstart
Build from source, run a local chain, and the command-line reference.
On this page · 8
Requirements
| Tool | Version | Notes |
|---|---|---|
| rustup | 1.97.1 (pinned) | Installed from rust-toolchain.toml on first use. MSRV 1.90. Needs a C compiler and ar (Xcode command-line tools on macOS, build-essential on Ubuntu). |
| elan | Lean v4.36.0 | Pinned in core/lean-toolchain, fetched automatically (about 3 GB). brew install elan-init on macOS. No Mathlib. |
Tested on macOS (Apple Silicon) and Ubuntu 22.04 / 24.04 (x86_64, arm64).
xcode-select --install # C compiler, ar
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # rustup
brew install elan-init # elan (Lean)
sudo apt-get install -y build-essential curl git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none
Build and test
cargo build --release # runs lake build first: every proof is checked
cargo test # whole workspace
./scripts/check.sh # fmt, clippy -D warnings, lake build, all tests
| Suite | Covers |
|---|---|
| (cd core && lake build) | Proofs, compile-time #guard tests, axiom audit |
| cargo test -p leansvm-core-ffi --test smoke | Rust → Lean: consensus, ledger, fees |
| cargo test -p leansvm-core-ffi --test crypto | NIST ACVP vectors, cross-check against RustCrypto |
| cargo test -p leansvm-core-ffi --test boundary | FFI fuzzing, theorems re-checked at runtime |
| cargo test -p leansvm-core-ffi --test lean_rules | Layering and forbidden constructs in the Lean sources |
| cargo test -p leansvm-node --lib | Block log, snapshots, HTTP parsing, genesis, slot clock |
| cargo test -p leansvm-node --test in_process | Node driven slot by slot: blocks, snapshots, verify |
| cargo test -p leansvm-node --test e2e | Real process: kill -9, restart, recovery |
Local chain
# keys: each prints its address; key files are hex seeds, mode 0600
leansvm keygen alice.key
leansvm keygen treasury.key
# genesis: allocations must sum to exactly 1,000,000 tokens
leansvm-node init data --chain-id 1 \
--alloc <alice address>:1000 \
--alloc <treasury address>:999000
# run: safe to stop at any time (Ctrl-C or kill -9)
leansvm-node run data --rpc 127.0.0.1:8650
# use, from another terminal
leansvm send alice.key <recipient address> 12.5
leansvm status
Testnet
The public testnet runs the same node with a faucet in front. Get tokens on the faucet page or with curl, then use the CLI against the testnet with --rpc. Testnet tokens have no value.
leansvm keygen alice.key # prints the address
curl -s -X POST https://testnet.leansvm.xyz/faucet/<alice address>
leansvm balance <alice address> --rpc testnet.leansvm.xyz:80
leansvm send alice.key <recipient address> 1 --rpc testnet.leansvm.xyz:80
Over plain HTTP anyone on the network path can change what the node seems to answer, including the fees send picks by default. That is acceptable for worthless test tokens; to run a test network of your own, see docs/node.md.
leansvm-node
| Command | Option | Default | Meaning |
|---|---|---|---|
| init <dir> | --chain-id N | required | Chain id, part of every signed transaction. |
| --alloc ADDR:TOKENS | required | Genesis balance; repeatable; must sum to 1,000,000 tokens. | |
| --slot-ms N | 1000 | Slot length in milliseconds. | |
| --fee-floor N | 1 | Minimum base fee, units per byte. | |
| --block-target-bytes N | 500000 | Fee target; a block holds at most twice this. | |
| run <dir> | --rpc HOST:PORT | 127.0.0.1:8650 | HTTP listen address. |
| --snapshot-every N | 3600 | Slots between snapshots; also how long rejected/dropped statuses are kept. | |
| --mempool-size N | 10000 | Mempool capacity in transactions. | |
| verify <dir> | Replay a stopped node’s log from genesis; compare snapshots, index and consensus state. |
init refuses a directory that already has a genesis.txt, sets genesis_time_ms to the current time and writes validator.key (mode 0600, never overwritten). For a repeated option the last value wins, except --alloc.
leansvm
| Command | Meaning |
|---|---|
| keygen <file> | Write a new key file (32-byte seed, hex, mode 0600) and print its address. |
| address <file> | Print the address of a key file. |
| send <key> <to> <tokens> | Sign and submit, then poll /tx every 200 ms for up to 30 s, resubmitting on 404 and stopping on a rejection or drop. --priority-fee-per-byte (default: the account’s min_priority_fee), --max-fee-per-byte (default: 2 × base fee + priority), --no-wait. Attaches the public key when the account has none bound and nothing pending. |
| balance <address> | Balance, nonce, key bound. --json for the raw response. |
| status | Chain, slot, finalized slot, base fee, cost of a normal transfer, supply, burned, mempool. --json. |
| tx <id> | Transaction and status (JSON). |
| block <height | hash> | Block with its transactions (JSON). |
| history <address> | Account transactions, newest first (JSON); --before HEIGHT.INDEX. |
--rpc HOST:PORT (default 127.0.0.1:8650) works with every command. Amounts are tokens with at most 9 decimals. leansvm speaks plain HTTP only. It reaches the public testnet through --rpc testnet.leansvm.xyz:80; browsers and curl use https://testnet.leansvm.xyz (see HTTP API).
Ubuntu service
./scripts/install-ubuntu.sh # first install and every update; --skip-tests, --no-restart
sudo systemctl edit leansvm-node # local overrides (the script rewrites the unit)
journalctl -u leansvm-node -f
sudo -u leansvm leansvm-node verify /var/lib/leansvm # service stopped
| Item | Value |
|---|---|
| Binaries | /usr/local/bin/leansvm-node, /usr/local/bin/leansvm |
| Data directory | /var/lib/leansvm (mode 0700, user leansvm) |
| Unit | deploy/leansvm-node.service → /etc/systemd/system |
| Runtime dependencies | glibc, libm, libgcc_s (Lean’s libc++ is linked statically) |
| Sandbox | unprivileged user, read-only view of the system, restart on failure |
Load test
cargo run --release -p leansvm-node --example load -- \
--key treasury.key --rpc 127.0.0.1:8650 --accounts 1000 --txs 10 [--rate 150]
Funds --accounts new accounts, sends --txs transfers from each (all at once, or at --rate per second), waits until all are applied, then checks every balance and that supply + burned = genesis supply. Resubmits what a restarted node lost, so it can run while the node is killed. See also measured results.