A cryptocurrency and blockchain prototype in Python.
Cryptonomicon implements a compact blockchain system in a single Python project. It includes proof-of-work mining, RSA-based wallets, simple on-chain transfers, serialization, and chain validation. The codebase is designed to be small, readable, and easy to run locally.
- Proof of Work: Mining blocks with adjustable difficulty
- Wallets: RSA key generation, address derivation, signing, and JSON export/import
- Transactions: Simple transfer records in the active blockchain flow
- Validation: Block hash, link, and proof-of-work verification
- Serialization: Save and load wallets and blockchain state from disk
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
python3 -m pip install -r requirements.txt
# Launch the interactive CLI
python3 main.pyCryptonomicon ships a single interactive CLI in main.py that exposes all
functionality through a numbered menu:
| Option | Action |
|---|---|
| 1 | Create a new wallet (generates an RSA key pair and saves it to a JSON file) |
| 2 | Load an existing wallet from a JSON file |
| 3 | Check the balance of an address |
| 4 | Mine a new block (collects pending transactions + mining reward) |
| 5 | Send a transaction to another address |
| 6 | View the full blockchain |
| 7 | Validate blockchain integrity |
| 8 | Save the blockchain to a JSON file |
| 9 | Load a blockchain from a JSON file |
| 0 | Exit |
Typical workflow:
python3 main.py
# 1 — create a wallet (save as miner.json)
# 4 — mine a block to earn coins
# 1 — create a second wallet (save as recipient.json)
# 5 — send coins to the recipient address
# 4 — mine another block to confirm the transaction
# 6 — view the chain to inspect both blocksYou can also import the core classes directly in a Python shell for scripting or exploration:
from blockchain import Blockchain
from wallet import Wallet
bc = Blockchain(difficulty=2) # lower difficulty for quick testing
w = Wallet()
print(w.address)
bc.mine_pending_transactions(w.address)
print(bc.get_balance(w.address)) # 50 coinsblock.py- Block class and proof-of-work logicblockchain.py- Chain management, pending transactions, persistence, and validationtransaction.py- Experimental UTXO-style transaction classes not yet used by the CLI flowwallet.py- Wallet with RSA key managementmain.py- Interactive CLI interfacetest_basic.py- Basic smoke test scriptDEVELOPMENT.md- Development and architecture notes
- The active blockchain path stores transactions as simple dictionaries rather than full UTXO objects.
- The richer transaction model in
transaction.pyis only partially integrated. - Pending transactions receive basic structural validation, but the chain does not yet enforce full signature verification.
- Balances are computed by scanning every block instead of using an indexed state model.
Install dependencies first, then run:
python3 -m compileall .
python3 test_basic.pypytest-style tests are not currently included as a dependency or maintained as
part of the default workflow.
Contributions are welcome. To get started:
- Fork the repository and create a feature branch from
main. - Set up your environment using the steps in Quick Start.
- Make your changes. Keep commits focused and atomic.
- Run the verification commands from Testing.
- Open a pull request against
mainwith a short description of the change and what it changes.
MIT. See LICENSE.