HTTP API
Endpoints, response fields, status codes, pagination, connection limits and metrics.
On this page · 9
Conventions
- Testnet
- https://testnet.leansvm.xyz
- Testnet, plain HTTP
- http://testnet.leansvm.xyz:80 (for the leansvm CLI)
- Own node
- http://127.0.0.1:8650 (--rpc default)
- Protocol
- HTTP/1.1, JSON responses
- Amounts
- integer units (10^9 per token)
- Hashes, ids, addresses
- lowercase hex
- CORS
- Allow-Origin *, GET POST OPTIONS, max-age 86400
- Connection
- close after each response
- Errors
- {"error": "<message>"}
- Preflight
- OPTIONS → 204
Paths on this page are relative to the base URL. The public testnet is at https://testnet.leansvm.xyz; port 80 of the same host serves it over plain HTTP for the leansvm CLI, which does not speak TLS. A node you run yourself serves the same API over plain HTTP on the address given to leansvm-node run --rpc, 127.0.0.1:8650 by default.
Chain
GET/status
chain_id, slot, height, finalized_slot, finalized_hash, base_fee, total_supply, burned, mempool, mempool_min_priority_fee. The last field is the priority fee per byte a new transaction from an account with nothing waiting needs to enter a full mempool.GET/block/<height or hash>
height, slot, hash, parent, proposer, txs, tx_bytes, base_fee, fees, transactions (array).GET/blocks?before=H&limit=N
{"blocks": [...], "next": H | null}, newest first. Pass next as before for the following page. A 64-character argument to /block/ is read as a hash, anything else as a height.Accounts
GET/account/<address>
address, balance, nonce, next_nonce, key_bound, min_priority_fee. next_nonce counts transactions still in the mempool; it is the nonce the next transaction must use. min_priority_fee is the priority fee per byte the account’s next transaction needs to enter a full mempool, which never evicts the account’s own transactions (0 while there is room).GET/account/<address>/txs?before=H.I&limit=N
{"txs": [...], "next": "H.I" | null}: transactions the account sent or received, newest first. H.I is block height and index within the block.Transactions
POST/tx
{"id"} when admitted to the mempool, 400 {"error"} otherwise.GET/tx/<id>
| status | Fields |
|---|---|
| applied | id, height, slot, index, sender, recipient, amount, nonce, max_fee_per_byte, priority_fee_per_byte, fee, size |
| pending | id, sender, recipient, amount, nonce, max_fee_per_byte, priority_fee_per_byte, size |
| rejected | reason: TxError name, e.g. FeeTooLow |
| dropped | reason: evicted, replaced or expired |
Lookup order: mempool → remembered statuses (one snapshot interval) → chain index (permanent) → 404. The mempool is not persisted, so a transaction pending before a restart returns 404 afterwards.
curl -s https://testnet.leansvm.xyz/status
curl -s https://testnet.leansvm.xyz/account/<address>
curl -s https://testnet.leansvm.xyz/tx/<id>
curl -s --data-binary @tx.bin https://testnet.leansvm.xyz/tx # raw v3 transaction
# leansvm speaks plain HTTP: --rpc testnet.leansvm.xyz:80 for the testnet, default 127.0.0.1:8650
leansvm status --json
leansvm balance <address> --json
leansvm tx <id>
leansvm send alice.key <address> 12.5 # builds, signs and posts
Faucet
The testnet runs a faucet (leansvm-faucet) on the same host. It pays a fixed amount to any address that asks, once per address and once per client within a cooldown, and stops for the rest of the hour after a set number of payouts. The faucet page uses these two requests.
GET/faucet
address, balance, amount (units per payout), cooldown_secs, per_hour.POST/faucet/<address>
{id, amount} with the id of the transfer; 429 {error, retry_after} (seconds) when the address or the client was paid within the cooldown or the hourly limit is reached; 503 when the node refused the transfer.curl -s -X POST https://testnet.leansvm.xyz/faucet/<address>
Pagination
limit defaults to 20 and is clamped to 1–100. next is the cursor for the following page, or null at the end. History queries are served from the index on the HTTP threads and never reach the main thread.
Limits
| Limit | Value | Response |
|---|---|---|
| Request headers | 8 KiB | 400 headers too large |
| Request body | 16 KiB | 413 body too large |
| Time to send a request | 10 s | 408 request timed out |
| Connections | 64 | 503 too many connections |
| Connections per address | 16 | 429 too many connections from this address |
| Requests per address | burst 100, refill 50 / s | 429 too many requests |
| Queue to the main thread | 1,024 | 503 the node is busy; try again |
| Main thread answer | 10 s | 503 the node did not answer |
| Response write | 5 s | connection closed |
Loopback addresses (127.0.0.0/8, ::1, also IPv4-mapped) are exempt from the per-address limits; a reverse proxy on the same machine must apply its own. The main thread stops answering when the next slot is due, so request load cannot delay block production.
Status codes
| Code | When |
|---|---|
| 200 | JSON result |
| 202 | POST /tx admitted: {"id": "<hex>"} |
| 204 | OPTIONS preflight |
| 400 | malformed request (headers, Content-Length, hex, limit, before, height) or a refused transaction; see mempool errors |
| 404 | not found, unknown transaction, unknown block |
| 408 | request not received within 10 s |
| 413 | body over 16 KiB |
| 429 | per-address connection or rate limit |
| 503 | connection limit, main thread busy or not answering, shutting down, index error |
Metrics
GET/metrics
leansvm_.| Type | Metrics |
|---|---|
| gauge | slot, height, finalized_slot, base_fee, burned_units, mempool_transactions, mempool_min_priority_fee, accounts, tx_statuses, slot_seconds, slot_seconds_max, block_build_seconds, index_seconds, snapshot_seconds, startup_seconds, replayed_blocks, replayed_txs, clock_offset_slots |
| counter | blocks_finalized_total, txs_admitted_total, txs_refused_total, txs_applied_total, txs_rejected_total, txs_evicted_total, txs_replaced_total, txs_expired_total, snapshots_written_total, snapshot_failures_total |