The Aim of The Project is to provide a Visual Simualtion of Blockchain World for those who are new to this Technology
Live Demo https://blockchaingo.herokuapp.com/
Checkout the live demo here
- The Webapp may take 20 -30 sec to Load
- Prefer Desktop to access the website
Make sure you have Go version 1.12 or newer.
$ git clone https://github.com/atharvau/Blockchain_in_GO
$ cd Blockchain_in_GO
$ go get -u github.com/gin-gonic/gin
$ go build Main.go
Your app should now be running on localhost:2222.
Blockchain in GoLang is a Golang Project which consists simualtion of two blockchains
- Simple Blockchain
- Crypto Blockchain
It gives visual feel of the blockchain data structure to easly understand the concepts. Features of the blockchain are
Blockchain | Consensus Algorithm | Stored Data |
---|---|---|
Simple | Proof-of-Work | String Data |
Crypto | Proof-of-Work | Transaction Data |
An awesome project.
- BackEnd : GOLANG-Gin
- FrontEnd : HTML CSS Jquery
- Deployement :Heroku
project
│ README.md
│ main.go
│ Procfile
│ app.json
│ heroku.yml
└───folder1
a.html
index.html
crypto.html
index.css
The main.go is the Main file which has implementation of Blockchain and a server to serve It. The Template Folder Consists of All Front End Html Css And JS files required in Front End The Remaining files in root directory are autogenrated deployement files required for hosting on Heroku
The main.go can be categorized into 1. blockchain implementaion 2.Server Code The Server Code consits typical GET Request and Responses for handling incoming requests from FrontEnd The Blockchain Implementation consists 2 Chains Structure
- Simple
- Structure
type Block struct {
PrevHash string
CurrHash string
Data string
Nonce uint64
Timestamp int64
Index uint64
Validate bool
}
- Methods
func AddBlock(PrevHash string, Data string, blockchain []Block) []Block
func SetBlock(blockchain []Block, pos uint64, Data string) []Block
func ReMine(blockchain []Block)
func ValidateChain(blockchain []Block) []Block
func ProofOfWork
func GetMD5Hash(text string) string
- Crypto
- Structure
type CryptoBlock struct {
PrevHash string
CurrHash string
Nonce uint64
Timestamp int64
Index uint64
Validate bool
Data TransInfo
}
type TransInfo struct {
Sender string
Reciver string
Amount uint64
Miner string
}
type Wallet struct {
Name string
Amount uint64
Address string
}
- Methods
func CryptoAddBlock(Data TransInfo, Prevhash string, blockchain []CryptoBlock) []CryptoBlock
func ProofOfWork2(str string) CryptoBlock
func CryptoValidateChain(blockchain []CryptoBlock) []CryptoBlock
func CryptoReMine(blockchain []CryptoBlock)
func CryptoSetBlock(blockchain []CryptoBlock, pos uint64, Data TransInfo) []CryptoBlock
func CryptoCalculate(blockchain []CryptoBlock) []Wallet
New Block Can be added by inputing a string and click add new data
Difficulty is a measure of how difficult it is to find a hash below a given target
The Blockchain can be cleared easily cleared by clicking
You can Change the contents of blockchain by inputing data and clicking Change Data Button It Corrupts the blockchain and display corrupted Chain in Red Color
The Crypto chain is provided with 3 default Wallets
Name | Account | Default CryptoCoin |
---|---|---|
Steve | 0x111111 | 51 |
Mark | 0x222222 | 51 |
Bill | 0x333333 | 51 |
The Mining Reward is 1 CryptoCoin
- Select The Sender
- Select The Reciver
- Select The Miner
- Select the Amount to Transfer
- Select the Transfer button and wait till it mines new Block
- We're are open to enhancements & bug-fixes.
- Feel free to add issues and submit patches.