Is it possible to create a cryptocurrency with minimal code?

4 replies 428 views
jake51Member
Posts: 10 · Reputation: 186
#1Oct 5, 2017, 04:26 PM
I’m curious: what’s the least amount of code you’d need to make a basic cryptocurrency with a blockchain? I came across this project with around 5000 lines of code. Do you think it’s feasible to whip up a cryptocurrency in under 1000 lines if you use external libraries for P2P and cryptography? By basic functionality, I mean it should be able to: - Create a blockchain - Mine new blocks that generate coins - Validate those blocks - Set up accounts and check balances - Transfer coins between accounts - Adjust difficulty (like just bumping up a difficulty counter every few blocks) I hope I covered everything. Also, could a cryptocurrency with a DAG structure have a smaller codebase than one using blockchain? How tough would it be to implement a DAG or other non-traditional ledgers?
6 Reply Quote Share
jake51Member
Posts: 10 · Reputation: 186
#2Oct 5, 2017, 05:26 PM
Found early testnet prototype of Virel block chain, only 11339 lines, and that with tests! https://github.com/virel-project/virel-blockchain/commit/89a9a80e30c2a10b85c309cdb77026f834174f41 So 1000 lines of code seem doable.
3 Reply Quote Share
jake51Member
Posts: 10 · Reputation: 186
#3Oct 5, 2017, 08:02 PM
There is this, Python version is ~2500 LOC https://github.com/zack-bitcoin/basiccoin
4 Reply Quote Share
paul.ninjaFull Member
Posts: 152 · Reputation: 539
#4Oct 6, 2017, 12:08 AM
Below 1k lines is totally doable for a play/test coin if you lean on libraries. Maybe you'll want to keep it a linear PoW chain, UTXO only, single-sig (ed25519/secp via a lib), no scripting, fixed block/tx format, naive mempool and longest-chain reorgs. In Python/Go that should be around 700-1200 lines of code if my estimates are correct.
3 Reply Quote Share
jake51Member
Posts: 10 · Reputation: 186
#5Oct 6, 2017, 12:33 AM
Found https://github.com/jstnryan/cruzbit Written in Go, around 11k lines for main stuff, without wallet or client. Net is still alive.
4 Reply Quote Share

Related topics