Gochain is a Blockchain written in go

Overview

gochain

gochain is a proof-of-work blockchain written in go.

Features

  • Proof-Of-Work
  • Persistence
  • CLI
  • Transactions
  • Addresses
  • Merkle Tree
  • Network

How to run the gochain network

First, set NODE_ID to 3000 (export NODE_ID=3000) in the first terminal window. Create a wallet and a new blockchain on the NODE 3000 terminal:

$ go run .createblockchain -address <address3000>

After that, the blockchain will contain only the genesis block. We need to save the block and use it in other nodes.

$ cp blockchain_3000.db blockchain_genesis.db 

Next, open a the terminal window of your second Node and set node ID to 3001. This will be a wallet node. Generate some addresses with go run .createwallet.

Back to the first window send some coins to the wallet addresses:

$ go run . send -from <address3000> -to <address3001> -amount 10 -mine

-mine flag means that the block will be immediately mined by the same node.

Start the node:

$ go run . startnode

The node must be running until the end of the scenario.

Start the blockchain of NODE 3001 with the genesis block saved above:

$ cp blockchain_genesis.db blockchain_3001.db

Run the node:

$ go run . startnode

It'll download all the blocks from the 3000 node. To check that everything's ok, stop the node and check the balances:

$ go run . getbalance -address <address3001>
Balance of '<address3001>': 10

Also, you can check the balance of the NODE 3000 address, because the node 3001 now has its blockchain:

$ go run . getbalance -address <address3000>
Balance of '<address3000>': 10

Open a new terminal window and set its ID to 3002, and generate a wallet. This will be a miner node. Initialize the blockchain:

$ cp blockchain_genesis.db blockchain_3002.db

And start the node:

$ go run . startnode -miner <address3002>

Send some coins from NODE 3001:

$ go run . send -from <address3001> -to <address3002> -amount 1
$ go run . send -from <address3001> -to <address3000> -amount 1

Quickly! Switch to the miner node 3002 and see it mining a new block! Also, check the output of the central node.

Switch to the node 3001 and start it:

$ go run . startnode

It'll download the newly mined block!

Stop it and check balances:

$ go run . getbalance -address <address3001>
Balance of 'WALLET_1': 8

Research and ToDos

  • Target Adjusting Algorithm
  • Sharding
  • Test other consensus methods
  • Block Explorer (Web)

Ressources

Contact

You might also like...
 Implementing blockchain using Golang ✔️
Implementing blockchain using Golang ✔️

Implementing blockchain using Golang ✔️ Keys The Blockchain uses ECDSA (224 bits) keys.

LINE Financial Blockchain forked from gaia

LFB(LINE Financial Blockchain) This repository hosts LFB(LINE Financial Blockchain). This repository is forked from gaia at 2021-03-15. LFB is a mainn

utreexo blockchain skeleton
utreexo blockchain skeleton

sunyata sunyata is a blockchain skeleton. It implements a minimally-functional proof-of-work blockchain, including consensus algorithms, p2p networkin

OmniFlix Hub is a blockchain built using Cosmos SDK and Tendermint and created with Starport.

OmniFlix Hub is the root chain of the OmniFlix Network. Sovereign chains and DAOs connect to the OmniFlix Hub to manage their web2 & web3 media operations (mint, manage, distribute & monetize) as well as community interactions.

A plugin that turn hashicorp vault into blockchain wallet.
A plugin that turn hashicorp vault into blockchain wallet.

dq-vault - Hashicorp vault BTC/ETH plugin This vault plugin stores a user's mnemonic inside vault in an encrypted manner. The plugin uses this stored

Tools to help teams develop smart contracts on the Cardano blockchain
Tools to help teams develop smart contracts on the Cardano blockchain

toolkit-for-cardano toolkit-for-cardano simplifies the development of Cardano smart contracts by providing teams with frequently needed tasks: Build T

Yu is a highly customizable blockchain framework.
Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Use golang to reproduce the basic blockchain

Blockchain_with_Go Use golang to reproduce the basic blockchain Update Panel V0.1 No transactions but noly blocks are allowed. V0.5 Transactions are n

Yu is a highly customizable blockchain framework.
Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Releases(v0.1)
  • v0.1(Jun 25, 2021)

Owner
Jonas Ampferl
19 years old Software Engineer from Ingolstadt, Germany.
Jonas Ampferl
Stackledger: a new blockchain written in golang

StackLedger Stackledger is a new blockchain. It is written in golang and uses a novel networking stack built from two primitives: channels and extensi

null 1 Feb 21, 2022
goBlockChain is a version of the classic blockChain with POW algorithms written in golang.

goBlockChain is a version of the classic blockChain with POW algorithms written in golang. May come in handy when learning about this technology.

Alexandr Primak 1 Oct 31, 2021
A basic blockchain implementation written in Go

Blockchain Having fun implementing a blockchain using Golang. Using Minimum Viable Blockchain Keys The Blockchain uses ECDSA (224 bits) keys. When a u

Jorge Izquierdo 822 Dec 29, 2022
DERO Homomorphic Encryption Blockchain Protocol

Homomorphic encryption is a form of encryption allowing one to perform calculations on encrypted data without decrypting it first. The result of the computation is in an encrypted form, when decrypted the output is the same as if the operations had been performed on the unencrypted data.

null 122 Dec 27, 2022
A simplified blockchain implementation in Golang

A simplified blockchain implementation in Golang

Ivan Kuznetsov 3.7k Dec 31, 2022
DERO: Secure, Anonymous Blockchain with Smart Contracts. Subscribe to Dero announcements by sending mail to [email protected] with subject: subscribe announcements

Welcome to the Dero Project DERO News Forum Wiki Explorer Source Twitter Discord Github Stats WebWallet Medium Table of Contents ABOUT DERO PROJECT DE

null 275 Dec 7, 2022
run ABI encoded data against the ethereum blockchain

Run EVM code against a database at a certain block height - Note You can't run this against a running geth node - because that would share the db and

Edgar Aroutiounian 60 Nov 11, 2021
Go module for the Cardano Blockchain

cardano-go cardano-go is both a library for creating go applicactions that interact with the Cardano Blockchain as well as a CLI to manage Cardano Wal

Alonso Villegas 38 Dec 1, 2022
chia-blockchain some function implement in golang

gochia chia-blockchain some function implement in golang Package bls-signatures implement blspy Usage? Now we can use it to generate plot memo and id,

Kure 8 May 27, 2022
Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint.

Frontier Chain Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint. Setup Initialize the blockchain with one validator no

Frontier 12 Jul 12, 2022