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?
Is it possible to create a cryptocurrency with minimal code?
4 replies 428 views
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.
There is this, Python version is ~2500 LOC
https://github.com/zack-bitcoin/basiccoin
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.
Found https://github.com/jstnryan/cruzbit
Written in Go, around 11k lines for main stuff, without wallet or client. Net is still alive.