A basic implementation of Blockchain

GoChain

A basic implementation of blockchain in go.

Building

$ cd cmd
$ go build -o gochain

Usage

Starting a node

You can start as many nodes as you want with the following command

./gochain -port=<port-number>

Endpoints

Requesting the Blockchain of a node

  • GET 127.0.0.1:8000/chain

Mining some coins

  • GET 127.0.0.1:8000/mine

Adding a new transaction

  • POST 127.0.0.1:8000/transactions/new

  • Body: A transaction to be added

    {
      "sender": "sender-address-te33412uywq89234g",
      "recipient": "recipient-address-j3h45jk23hjk543gf",
      "amount": 1000
    }

Register a new node in the network

Currently you must add each new node to each running node.

  • POST 127.0.0.1:8000/nodes/register

  • Body: A list of nodes to add

    {
       "nodes": ["http://127.0.0.1:8001", <more-nodes>]
    }

Resolving Blockchain differences in each node

  • GET 127.0.0.1:8000/nodes/resolve
Comments
  • Package issue?

    Package issue?

    Hi Cristian, I get the following error when I build. Thank you for clue.

    gochain/cmd(master*) » go build -o gobuild
    main.go:6:5: cannot find package "github.com/crisadamo/gochain" in any of: /usr/local/Cellar/go/1.8.1/libexec/src/github.com/crisadamo/gochain (from $GOROOT) /Users/eos/go/src/github.com/crisadamo/gochain (from $GOPATH)

  • Hashing of blocks is not working

    Hashing of blocks is not working

    Hi,

    Nice project. Was working on a Go Blockchain implementation myself and noticed that your hashing always returns the same hash, throughout the entire chain.

    The thing is that you are trying to hash a block with binary.Write(&buf, binary.BigEndian, block) which gives you an error you don't handle. The data for binary.Write must be a fixed-size value, your Block contains a string which isn't fixed size.

    I've made a workaround by marshalling the block first, that way the binary.Write succeeds and your hashing the chain properly. It is a bit slow though, if you'll find a better solution, drop me a line.

    You can see it here, feel free to use it: https://github.com/Grrrben/gocoin/blob/master/blockchain.go#L55

    Cheers.

  • corrects readme and fixes headers not being written correctly

    corrects readme and fixes headers not being written correctly

    The command to run the script with a non-default port needed to be ./gochain -port=5000 instead of ./gochain 5000.

    Also, in order for the HTTP response to be encoded correctly, in the buildResponse function, w.Header().Set("Content-Type", "application/json") needs to come before w.WriteHeader(resp.statusCode)

  • Missing previous hash

    Missing previous hash

    Looks like you're not supplying the previous hash when mining?

    https://github.com/crisadamo/gochain/blob/fc3aa97147b0634d043c56db4ef6900ee3116cce/handler.go#L100

    Awesome work - this is a really useful resource!

  • Cannot find Package Error

    Cannot find Package Error

    Hi there, I was going through your code. However , i am not able to run the go code.

    When i run : go build -o gochain

    ERROR:

    main.go:6:5: cannot find package "github.com/crisadamo/gochain" in any of: /usr/local/go/src/github.com/crisadamo/gochain (from $GOROOT) ($GOPATH not set

    Please mind that i have just started with this technology. Kindly Help. Good Day!

  • HTTP is slow, switch to rpc

    HTTP is slow, switch to rpc

    Switch form HTTP too RPC to increase the performance of every request and you get a lot of additional features which HTTP don't have.

    This project seems pretty interesting. I can offer you my help to speed up the development process.

    contact me anytime ;)

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

Dec 29, 2022
Blockchain-go - A repository that houses a blockchain implemented in Go

blockchain-go This is a repository that houses a blockchain implemented in Go. F

May 1, 2022
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

Dec 30, 2022
A simplified blockchain implementation in Golang

A simplified blockchain implementation in Golang

Dec 31, 2022
Implementation of blockchain using golang

go-blockchain Basic implementation of blockchain using golang. Initialize Blockc

Feb 18, 2022
Mini Blockchain Implementation In Golang Inspired by Go-Ethereum🚀

JP Blockchain ?? ?? Mini Blockchain Implementation In Golang Inspired by Go Ethereum & BlockChain Bar by Lukas (Web3Coach) Features Working Core Compo

Aug 8, 2022
Blockchain implementation with Go

Ultra Basic Blockchain with Go Ultra-basic blockchain implementation with Go. Ru

Feb 17, 2022
Kava - Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the cosmos-sdk

DeFi for Crypto. Telegram | Medium | Discord Reference implementation of Kava, a

Apr 4, 2022
DERO Homomorphic Encryption Blockchain Protocol
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.

Dec 27, 2022
DERO: Secure, Anonymous Blockchain with Smart Contracts. Subscribe to Dero announcements by sending mail to [email protected] with subject: subscribe announcements
DERO: Secure, Anonymous Blockchain with Smart Contracts.  Subscribe to Dero announcements by sending mail to lists@dero.io 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

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

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

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,

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

Jul 12, 2022
Implementing blockchain using Golang ✔️
 Implementing blockchain using Golang ✔️

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

May 24, 2022
Gochain is a Blockchain written in go
Gochain is a Blockchain written in go

gochain gochain is a proof-of-work blockchain written in go. Features Proof-Of-Work Persistence CLI Transactions Addresses Merkle Tree Network How to

Jul 14, 2022
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

Dec 21, 2022
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

May 24, 2022
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.

Nov 10, 2022