Blockchain

 
 
A blockchain is a distributed database managed by a peer-to-peer network. The distributed database is also called a ledger which is a continuously growing chain of blocks. Each block contains a number of records and each block is linked to a previous block.

It is extremely difficult to change a record in any given block without the alteration of all subsequent blocks and the collusion of the network.

The first implementation of a blockchain was Bitcoin in 2009 invented by an unknown programmer, or a group of programmers, under the name Satoshi Nakamoto.

After the Bitcoin success many blockchain implementations followed such as Litecoin and Peercoin.

Other blockchain implementations introduces new kind of functionalities such as Ethereum and Dash.







How to build go-ethereum on macOS



Information
Ethereum is an open-source, public, blockchain-based distributed computing platform featuring smart contract (scripting) functionality. It provides a decentralized virtual machine, the Ethereum Virtual Machine (EVM). This virtual machine can execute Turing-complete scripts using an international network of public nodes and a token called ether. Gas is used to prevent spam on the network and allocate resources proportionally to the incentive offered by the request.

The Ethereum homepage can be found at: https://www.ethereum.org/
The latest Ethereum documentation can be found at: http://ethdocs.org/en/latest/
The latest Solidity documentation can be found at: https://solidity.readthedocs.io/en/develop/
The latest Ethereum source code can be downloaded from: https://github.com/ethereum

Operating system used
macOS 10.12 Sierra

Software prerequisites
Homebrew

Procedure
  1. Install go, type: brew install go

    ONLY IF NEEDED:
    Add in your .bash_profile:
    • export PATH=$PATH:/usr/local/opt/go/libexec/bin
    • Open a new terminal and type: go version
      You will see: go version go1.8.3 darwin/amd64

  2. Clone the go-ethereum repository on your machine:
    Type: cd ~/tools (I assume you have <homedir>/tools folder created)
    Type: git clone https://github.com/ethereum/go-ethereum.git

  3. Show both remote and local branches.
    Type: cd ~/tools/go-ethereum
    Type: git branch -a

    You will see the following:
    * master
    remotes/origin/HEAD -> origin/master
    remotes/origin/gh-pages
    remotes/origin/master
    remotes/origin/poc8
    remotes/origin/release/0.9.36
    remotes/origin/release/1.0.0
    remotes/origin/release/1.0.1
    remotes/origin/release/1.1.0
    remotes/origin/release/1.2.1
    remotes/origin/release/1.3.0
    remotes/origin/release/1.3.2
    remotes/origin/release/1.3.3
    remotes/origin/release/1.3.4
    remotes/origin/release/1.3.5
    remotes/origin/release/1.3.6
    remotes/origin/release/1.4
    remotes/origin/release/1.5
    remotes/origin/release/1.6
    remotes/origin/revert-3224-04
    remotes/origin/revert-3514-gas64
    remotes/origin/swarm
    remotes/origin/verboseblockvalidation


  4. In this example we are interested in the remotes/origin/release/1.6.
    Checkout this release version locally.
    Type: git checkout remotes/origin/release/1.6

    You will see the following:
    * (HEAD detached at origin/release/1.6)
    master
    remotes/origin/HEAD -> origin/master
    remotes/origin/gh-pages
    :


    It is recommended not to use the master branch because it contains the latest development which might errors.

  5. Build the geth application.
    Type: cd ~/tools/go-ethereum
    Type: make geth

    You will see the following:
    build/env.sh go run build/ci.go install ./cmd/geth >>> /usr/local/Cellar/go/1.8.3/libexec/bin/go install -ldflags -X main.gitCommit = cf87713dd42162861b7ed227f79f0638a33571df -s -v ./cmd/geth
    github.com/ethereum/go-ethereum/common/hexutil
    github.com/ethereum/go-ethereum/common/math
    :
    github.com/ethereum/go-ethereum/cmd/geth
    Done building.
    Run "build/bin/geth" to launch geth.


  6. Update your .bash_profile:
    export PATH=$PATH:/<homedir>/tools/go-ethereum/build/bin

  7. Show more information about the go-ethereum command line interface.
    Open a new terminal and type:
    geth --help

  8. If you want to build another geth version, you need to undo all changes in the go-ethereum folder.
    Type: cd ~/tools/go-ethereum
    Type: git checkout -f
    Type: git clean -fd
    Type: git pull and start again with step 3.