Simple client-server blockchain implementation in Haskell. Features transaction signing, block validation, proof-of-work, reward management and wallet control. Uses hactors library for concurrent programming, RSA for security and hashable-generics for generic hashing functions.
First of all you will need to install stack
tool. You may do it using your favourite package manager or by running curl -sSL https://get.haskellstack.org/ | sh
(bad habit tho).
Next, cd
into project dir and run
stack build
After fighting off all dependency issues and reading all the warnings you may in the splendor of glory run
stack ghci
The REPL should appear.
Create two users (their private&public key pair):
radekkp <- newKeyPair
(_, michalpub) <- newKeyPair
Create server actor (the blockchain is not distributed yet, sorry :( ):
serv <- runServer
Create miner connected to the server that will use radek's key pair:
m <- runMiner radekkp serv
...and watch it mine! The server and the client will log some events. To kill the party you may just shut down the ghci
, or send ServerStop
and ClientStop
to the actors accordingly.
You may manually add new transactions. To make radek pay michal 30 radcoins do:
serv ! PushTransaction (makeTransaction radekkp michalpub 30)
Note that you may need to import Control.Concurrent.Actor
to use !
operator.