Skip to content

bcaton85/go-blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Blockchain Simulator

Description

A simulated Blockchain written in Go. Followed this article for creating a single node, originally in python. Added some features to get it running as a network.

Usage

This is a brief overview on how to get it running, for more detail read this blog post.

  1. First build the binary cd go-blockchain && go build

  2. Open two terminals and start two nodes: ./go-blockchain 8000 ./go-blockchain 8001

  3. Register the nodes with each other by hitting the /nodes/register endpoint:

curl --location --request POST \
'http://localhost:8000/nodes/register' \
--header 'Content-Type: application/json' \
--data-raw '{
 "nodes": [
  "http://localhost:8001"
  ]
}'
  1. Add transactions to the network:
curl --location --request POST \
'http://localhost:8000/transactions/new' \
--header 'Content-Type: application/json' \
--data-raw '{
 "sender":"sender1",
 "recipient":"recipient2",
 "amount": 12
}'
  1. View the current chain before we mine a block:
curl http://localhost:8000/chain
  1. Mine the block:
curl http://localhost:8000/mine
  1. Find the newly replaced chain on the second node:
curl http://localhost:8001/chain
  1. Create more transactions and mine more blocks.

About

Simulated Blockchain network written in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages