Run two local nodes
Initialize the first node and then initialize the second with the same public custodian manifest. Keep each ledger on its own local disk path. The setup command also generates private test wallets under the first node's directory.
$devnet = python -m chain.setup --directory .local/devnet | ConvertFrom-Json
python -m chain --db .local/replica/ledger.sqlite3 init .local/devnet/custodians.json
Start these commands in separate terminals. Each node polls the URLs given with --peer. Configure both directions when both nodes should receive blocks mined on the other node. The browser can open http://127.0.0.1:8765/ for the local website and explorer.
python -m chain.network --db .local/devnet/chain.sqlite --port 8765 --peer http://127.0.0.1:8766 --site site
python -m chain.network --db .local/replica/ledger.sqlite3 --port 8766 --peer http://127.0.0.1:8765
From the first terminal, mine on the first database and check the replica after two seconds.
python -m chain --db .local/devnet/chain.sqlite mine $devnet.miner --count 3
Invoke-RestMethod http://127.0.0.1:8766/api/status | Select-Object height, tip, peer_status
python -m chain --db .local/replica/ledger.sqlite3 verify
The server defaults to 127.0.0.1:8765. For machines on an isolated network, use their RFC 1918 IPv4 addresses for --host and plain HTTP --peer URLs. The local HTTP listener has no TLS or authentication. An explicitly configured https://HOST[:PORT] peer, such as https://bitkeelmark.org, defaults to port 443 and uses system certificate trust and hostname verification. The client requests only read endpoints and validates downloaded content through the ledger. RFC 1918, CPython HTTPS client
Explorer HTTP API
| GET path | JSON response |
|---|---|
/api/status |
Network, height, tip hash, genesis hash, supply, reserve, fixed difficulty, and static peers with state |
/api/genesis |
block with the genesis contents and custodians |
/api/blocks?limit=10&view=summary |
Recent block summaries and the exclusive height cursor next. Use before=next for the next older page. The default view includes complete blocks. |
/api/blocks?start=1&limit=10 |
blocks in ascending order from the requested height |
/api/blocks/{height-or-hash} |
block, summary with confirmations, reward credits, and transaction IDs |
/api/transactions/{txid} |
Signed transaction, sender, recipient, token ID where applicable, and block confirmations |
/api/accounts/{address} |
Base balance, nonce, paged activity, and paged token_balances. Use before=next_activity or tokens_after=next_token. |
/api/tokens |
Token definitions, circulating supply, and next. Use after=next for the next catalog page. |
/api/tokens/{token-id} |
Token definition and paged transaction history. Use before=next for older activity. |
/api/tokens/{token-id}/accounts/{address} |
Token definition and the account's exact balance |
/api/apps |
Native app definitions and next, which can be passed as after for the next catalog page |
/api/apps/{app-id} |
App owner, program, canonical state and revision, plus deployment and call activity. Use before=next for older activity. |
The tip and hash fields in status are equal. All *_atomic amounts, transaction amount and cap values, and nonce fields are decimal strings. BKMK has eight decimal places. Token definitions give their own decimal places. An unused valid address returns zero balance and nonce. Canonical confirmations equal the tip height minus the inclusion height plus one, so the current tip has one confirmation. Each response reads a single database snapshot.
Transaction IDs are SHA-256 over the ASCII prefix BKMK txid with a null terminator, the 32 raw genesis hash bytes, and the canonical signed transaction JSON. The index backfills from stored blocks when opening a pre-index database. Block commits, fork replacement, and replay verification cover transaction and activity records. Address histories include payments, reward credits, and token activity. Block pages allow up to 32 records and activity or token pages allow up to 50. The optional same-origin site serves a fixed public file list. SQLite query planning, SQLite cursor pagination, Python SHA-256
To update the offline explorer, run python -m chain.snapshot --db .local/devnet/chain.sqlite --output site/devnet.js, then open site/explorer.html. The snapshot includes the latest 100 blocks and genesis, with transaction lookups and address activity for those blocks. It stores balances for the observed addresses and genesis custodians at the saved tip. The token catalog includes the first 100 definitions plus tokens referenced by saved records or balances. It includes up to 100 positive token balances per saved address. The app catalog includes the first 100 definitions plus apps referenced by saved transactions. Each saved app includes its state at the saved tip. Live app activity uses an expression index on the app ID in the transaction records. ECMAScript BigInt, SQLite expression indexes
Peer protocol and limits
Version 1 uses GET /peer/v1/status and GET /peer/v1/blocks with start, limit, anchor_height, and anchor_hash. The receiver checks the network and genesis before requesting blocks. Each page has at most 16 blocks. A peer returns HTTP 409 if the anchor leaves its canonical chain. Extension batches each commit atomically through the ledger. A divergent chain is downloaded and replayed transactionally only when it has more cumulative work. The fixed difficulty makes greater height equivalent to greater work. The local chain stays in place at equal work. RFC 9110 safe methods
The service polls about every two seconds and fetches up to 128 extension blocks per peer per poll. Fork replacement downloads full history with a 64 MiB limit. Peer states are waiting, ready, incompatible, rejected, and unavailable. ready means the peer exchange succeeded, and further polls may still be needed to catch up. Discovery, transaction and share gossip, headers-first sync, and transport authentication are outside this peer protocol. The standalone relay handles transaction and share submission separately.
Tested on Windows with CPython 3.14.10 and SQLite 3.50.4. The network layer adds no Python package dependencies or assets. Python uses the Python Software Foundation License version 2 and SQLite is public domain. CPython server source, CPython client source, Python license, SQLite copyright