↑ ↓ navigate↵ open

Quickstart

Build from source, run a local chain, and the command-line reference.

On this page · 8
  1. 01Requirements
  2. 02Build and test
  3. 03Local chain
  4. 04Testnet
  5. 05leansvm-node
  6. 06leansvm
  7. 07Ubuntu service
  8. 08Load test

Requirements

ToolVersionNotes
rustup1.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).
elanLean v4.36.0Pinned 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).

shell
xcode-select --install                                         # C compiler, ar
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  # rustup
brew install elan-init                                         # elan (Lean)

Build and test

shell
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
SuiteCovers
(cd core && lake build)Proofs, compile-time #guard tests, axiom audit
cargo test -p leansvm-core-ffi --test smokeRust → Lean: consensus, ledger, fees
cargo test -p leansvm-core-ffi --test cryptoNIST ACVP vectors, cross-check against RustCrypto
cargo test -p leansvm-core-ffi --test boundaryFFI fuzzing, theorems re-checked at runtime
cargo test -p leansvm-core-ffi --test lean_rulesLayering and forbidden constructs in the Lean sources
cargo test -p leansvm-node --libBlock log, snapshots, HTTP parsing, genesis, slot clock
cargo test -p leansvm-node --test in_processNode driven slot by slot: blocks, snapshots, verify
cargo test -p leansvm-node --test e2eReal process: kill -9, restart, recovery

Local chain

shell
# 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.

shell
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

CommandOptionDefaultMeaning
init <dir>--chain-id NrequiredChain id, part of every signed transaction.
--alloc ADDR:TOKENSrequiredGenesis balance; repeatable; must sum to 1,000,000 tokens.
--slot-ms N1000Slot length in milliseconds.
--fee-floor N1Minimum base fee, units per byte.
--block-target-bytes N500000Fee target; a block holds at most twice this.
run <dir>--rpc HOST:PORT127.0.0.1:8650HTTP listen address.
--snapshot-every N3600Slots between snapshots; also how long rejected/dropped statuses are kept.
--mempool-size N10000Mempool 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

CommandMeaning
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.
statusChain, 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

shell
./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
ItemValue
Binaries/usr/local/bin/leansvm-node, /usr/local/bin/leansvm
Data directory/var/lib/leansvm (mode 0700, user leansvm)
Unitdeploy/leansvm-node.service → /etc/systemd/system
Runtime dependenciesglibc, libm, libgcc_s (Lean’s libc++ is linked statically)
Sandboxunprivileged user, read-only view of the system, restart on failure

Load test

shell
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.