Crackcoin is a very basic blockchain-free cryptocurrency PoC in Python. It's a project for discovering cryptocurrencies.
Note that this is a PoC that runs only on local networks and does not provide proper security. The code should only be used to get familiar with the building blocks for a cryptocurrency. Also, crackcoin should not be confused with the (dead) currency CrackCoin (CRACK) from 2014.
This project was created as an exercise after reading "Mastering Bitcoin: unlocking digital cryptocurrencies".
- Transaction-based mining as a PoC for a blockchain-free cryptocurrency
- Threading in Python
- Working with sockets in Python (UDP)
- ECC crypto / ECC public key compression/decompression
- Base58 encoding like bitcoin
- Having the whole thing work (wallet, crypto, validation, networking, mining, etc)
Most cryptocurrencies use a blockchain to validate transactions among other things. After years of running these networks it's beginning to look like blockchain-based currencies naturally evolve into a centralised network, because it's in the best interest of the participants to combine computing power to calculate solutions for blocks.
An interesting framework for a blockchain-free protocol is discussed in the paper "Blockchain-Free Cryptocurrencies: A Framework for Truly Decentralised Fast Transactions", which can be found here:
https://eprint.iacr.org/2016/871.pdf
Do note that crackcoin doesn't implement nearly as complex a protocol as described in the paper. But the transaction-based mining method was used as an inspiration for implementing the 'core' for crackcoin.
- First run
python crackcoin.py
- Then type
h
to see options and communicate with other crackcoin-nodes on the network
- Run
python generateGenesis.py
until a cool address pops up - Edit crackcoinBase.sql: replace the address for the transaction with transactionHash d34db33f in
transactions_outputs
with your generated address - Run crackcoin and wait until a confirmation is generated for d34db33f with a higher difficulty (>6) than the one in crackcoinBase.sql
- Replace the confirmation for d34db33f
- Share code on other nodes
- Manually replace your wallet keys and address with the address and keys generated by generateGenesis.py. This will allow you to 'spend' the genesis cash.
-
The GUI
- When you create a transaction, a confirmation is created and both the transaction and the confirmation are shared on the network (UDP broadcast).
- When using the broadcast option
b
, your crackcoin node will broadcast a request packet on the network. Any crackcoin node receiving the request will send all transactions and confirmations to you. This is so new nodes can 'sync'.
-
Network server (UDP)
- When the server receives a new transaction, it checks if the transaction is valid and adds it to the database ('ledger').
- When a confirmation is received, the transaction's confirmation is updated if the received difficulty is higher than the existing difficulty.
-
Mining
- The mining component simply creates confirmations for some transaction. These are just proof of work hashes for that transaction.
- Mining is done by hardening the transaction confirmation with the least difficulty.