Accounts and transactions
Address derivation, wire format v3, ids, units, validation errors, mempool rules and statuses.
On this page · 6
Accounts and addresses
address = SHA3-256("leansvm/address/v1/mldsa44" ‖ public_key) // 32 bytes
| Field | Type | Notes |
|---|---|---|
| balance | u64 | units |
| nonce | u64 | count of applied transactions sent; max 2^64 − 1 |
| key | Option<PublicKey> | bound by the first outgoing transaction, immutable afterwards |
The address is the map key and is not stored in the account. Accounts that have only received have no key; GET /account reports it as key_bound.
Wire format (v3)
- version · 1 B
- always 3
- signed fields · 104 B
- chain id, sender, recipient, amount, nonce, both fee limits
- has_pubkey · 1 B
- 0 or 1
- public key · 1,312 B
- first transaction of an account only
- signature · 2,420 B
- ML-DSA-44 over the signed fields
offset size field
0 1 version = 3
1 8 chain_id u64 LE ┐
9 32 sender │
41 32 recipient │ signed bytes (104)
73 8 amount u64 LE │
81 8 nonce u64 LE │
89 8 max_fee_per_byte u64 LE │
97 8 priority_fee_per_byte u64 LE ┘
105 1 has_pubkey (0 | 1)
106 1312 public_key only if has_pubkey = 1
106|1418 2420 signature ML-DSA-44, context "leansvm/tx/v1"
- size
- 106 + |pk| + 2,420
- normal
- 2,526 B
- with key (MAX_TX_SIZE)
- 3,838 B
- tx id
- SHA3-256(signed bytes ‖ signature)
- signature context
- leansvm/tx/v1
- signing
- ML-DSA-44, hedged
The id and the signature do not cover the version byte, the key flag or the key. A key is therefore only accepted when the account has none: otherwise a relay could attach a key to a signed transaction and raise its size, and fee, by 1,312 bytes. applyTx_canonical proves an applied transaction carried a key exactly when it bound one. Rust builds the format with TxBody and Tx::to_bytes (core-ffi/src/ledger.rs).
Validation (applyTx)
Checks in evaluation order. The code is what leansvm_apply_tx returns; the name appears in rejected statuses and API errors.
| Code | Error | Condition |
|---|---|---|
| 1 | WrongChain | tx.chain_id ≠ chain id |
| 2 | WrongAccount | account records passed in do not match sender / recipient |
| 3 | SelfTransfer | sender = recipient |
| 4 | BadNonce | tx.nonce ≠ sender.nonce |
| 5 | NonceExhausted | sender.nonce = 2^64 − 1 |
| 11 | FeeTooLow | max_fee_per_byte < base_fee |
| 12 | UnexpectedPubkey | key already bound and the tx carries one |
| 6 | MissingPubkey | no key bound and the tx carries none |
| 7 | PubkeyMismatch | address of the carried key ≠ sender |
| 8 | BadSignature | ML-DSA-44 verify fails under the bound or carried key |
| 9 | InsufficientBalance | balance < amount + fee |
| 10 | RecipientOverflow | recipient balance + amount ≥ 2^64 |
| 255 | (malformed) | input could not be decoded; Rust treats it as a bug and stops |
On success the core returns both accounts, the fee and whether a key was bound (TxEffect). An error changes nothing.
Units and supply
- UNITS_PER_TOKEN
- 10^9
- DECIMALS
- 9
- TOTAL_SUPPLY
- 10^15 units
- minting
- none
- supply change
- − burned fees
- invariant
- supply + burned = 10^15
Mempool admission
Ledger::precheck runs on POST /tx. It is not binding (the core decides when the block runs), and a differential test checks it accepts exactly what applyTx accepts.
| Rule | Value |
|---|---|
| Capacity | 10,000 txs (--mempool-size) |
| Per-account window | 64; nonce must equal next_nonce (no gaps) |
| Balance check | covers all waiting txs of the account at the current base fee |
| Effective tip | min(max_fee − base_fee, priority_fee); 0 if max_fee < base_fee |
| Admission when full | tip ≥ victim + max(victim / 10, 1) |
| Eviction victim | last tx of another account, lowest tip, newest on tie |
| Replacement (same nonce) | both fees ≥ old + max(old / 10, 1) |
| TTL | 3,600 slots; later txs of the account dropped with it |
| Failure in block | later txs of the account dropped; account resumes at the failed nonce |
| Persistence | none; resubmit after a restart |
| Error (HTTP 400) | Cause |
|---|---|
| could not decode the transaction | body is not a valid v3 transaction |
| transaction already known | same id in the mempool or already applied |
| transaction larger than a block | size > 2 × block_target_bytes |
| BadNonce: the account’s next nonce is N | gap or reused nonce |
| UnexpectedPubkey: an earlier transaction in the mempool carries the key | key sent twice |
| InsufficientBalance: the account’s waiting transactions already need N units | balance rule |
| a replacement must raise both fees by a tenth: … | replacement rule |
| mempool full: offer a priority fee of at least N units/byte | admission rule |
| WrongChain, BadSignature, FeeTooLow, … | precheck error names, as above |
Status
| status | Kept | Fields |
|---|---|---|
| pending | while waiting | id, sender, recipient, amount, nonce, max_fee_per_byte, priority_fee_per_byte, size |
| applied | forever (index) | + height, slot, index, fee |
| rejected | one snapshot interval | reason: error name |
| dropped | one snapshot interval | reason: evicted | replaced | expired |
Lookup order for GET /tx/<id>: mempool, remembered statuses, chain index, else 404. See HTTP API.