Blockchain made in Go with Proof of Work (PoW) using sha256
git clone https://github.com/lukzhang/GoLang_Blockchain.git
Open 3 terminals and go into root folder. We are going have 3 nodes. One will create a genesis block, one will mine and check for transactions, and the other will send a token to another wallet
cd golang-blockchain
set NODE_ID=3000
go run main.go createwallet
set NODE_ID=4000
go run main.go createwallet
set NODE_ID=5000
go run main.go createwallet
go run main.go createblockchain -address TERMINAL1 WALLET
cd tmp
cp -r blocks_3000 blocks_4000
cp -r blocks_3000 blocks_5000
cp -r blocks_3000 blocks_gen
cd ..
go run main.go send -from TERMINAL1 WALLET -to TERMINAL2 WALLET -amount 10 -mine
go run main.go startnode
In second terminal, start node as well. You will see the blocks being added to it syncs. Hence, terminal 1 contains a lead node in this case and is not completely decentralized
go run main.go startnode
go run main.go startnode -miner TERMINAL3 WALLET
In second terminal, ctrl+c to stop the node and send a transaction from the 10 tokens it received earlier
go run main.go send -from TERMINAL2 WALLET -to TERMINAL3 WALLET -amount 3
You will see 3 tokens being sent as the miner mines a block. Terminal 1 which is running the node will show the block hash that was mined
go run main.go startnode
go run main.go printchain