A centralized cryptocurrency for fun, experimentation, and learning. Built with Node.js, TypeScript, Express, and SQLite.
$BOND is a playful and educational blockchain implementation that simulates real-world crypto mechanics without decentralization headaches. It features a RESTful API for interacting with the blockchain, submitting transactions, mining blocks, and querying wallet balances. The project uses a centralized SQLite database to persist the blockchain. The mempool is stored in memory.
- Blockchain Core: Each block includes signed transactions, a timestamp, a nonce, and a hash pointer to the previous block.
- Proof of Work: Configurable mining difficulty (default: 16 leading zero bits in binary).
- ECDSA Signatures: Transactions are signed with
secp256k1. Sender addresses are SHA-256 hashes of the public key. - In-Memory Mempool: Stores pending transactions until a block is mined.
- Genesis Block: Awards 42 $BOND to a hardcoded address on first run.
- Wallet Tools: CLI utilities to generate keys, sign txs, and mine blocks.
- REST API: Full set of endpoints for blocks, balances, and transactions.
- Each block is an instance of
Block, containing: height,timestamp,transactions,previous_hash,nonce, andhash.- Block hash is computed as:
sha256(height + timestamp + JSON.stringify(transactions) + previous_hash + nonce)- Proof of Work: The block hash must have
DIFFICULTYleading zero bits (seeDIFFICULTY).
- Transactions are objects with:
sender,recipient,amount,timestamp,message,signature,publicKey, andtxid.- The sender address is the SHA-256 hash of the public key.
- Transactions are signed using ECDSA (secp256k1). The signature covers all transaction fields except
signatureandtxid. - Signature verification is handled by
verifySignature.
- Pending transactions are stored in-memory in
mempool. - Transactions are added to the mempool after signature and balance checks.
- SQLite is used for persistent storage.
- The blockchain is stored in a single
blockchaintable (see schema insrc/db/index.ts). - Genesis block is created automatically if the chain is empty.
- Install dependencies:
npm install- Build the project
npm run build- Start the server
npm startShows a welcome message
Returns the latest block in the chain.
Response
{
"height": 1,
"timestamp": "...",
"transactions": [],
"previous_hash": "9df7...",
"nonce": 4714,
"hash": "0000..."
}Get a list of all blocks in the chain.
Submit a new block.
Request Body
{
"height": 1,
"timestamp": "...",
"transactions": [],
"previous_hash": "9df7...",
"nonce": 4714,
"hash": "0000..."
}Response
{
"status": "OK"
}Get a list of confirmed transactions for a wallet address.
Add a new transaction to mempool.
Request
{
"sender": "c6c81...",
"recipient": "...",
"amount": 0.4,
"timestamp": "2025-06-17T22:43:30.036Z",
"message": "...",
"signature": "3045...",
"publicKey": "..."
}Get the current mining difficulty (number of leading zeros).
If mined blocks do not meet this requirement, they are rejected and will not be added to the blockchain.
Get the balance of a wallet.
Response
{
"balance": 41.2
}- All state is centralized in a single SQLite database.
- There is no peer-to-peer networking on consensus.