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 setup testrpc on macOS



Information
testrpc is a Node.js based Ethereum client for testing and development. It uses ethereumjs to simulate full client behavior and make developing Ethereum applications much faster. It's a complete blockchain-in-memory that runs only on your development machine. It processes transactions instantly instead of waiting for the default block time. It also includes all popular RPC functions and features (like events) and can be run deterministically to make development a breeze.

Information about testrpc, see: https://github.com/ethereumjs/testrpc

Operating system used
macOS 10.12 Sierra

Software prerequisites
Docker

Procedure
  1. I have the following versions installed:

    Type: node -v     (version = 8.0.0)
    Type: npm -v      (version = 5.0.3)

    ethereumjs-testrpc v3.0.3 requires an older node version (at least node 6.9.1).
    When i installed ethereumjs-testrpc v3.0.3 i got this error when i started testrpc:

    Error: The module '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/
    scrypt/build/Release/scrypt.node'
    was compiled against a different Node.js version using
    NODE_MODULE_VERSION 51. This version of Node.js requires
    NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
    the module (for instance, using `npm rebuild` or `npm install`).


    To fix this problem i must install an older node version (eg: node 6.9.1).
    But my other projects requires node 8.0.0.
    I decided not to install the npm ethereumjs-testrpc package, but implement the ethereumjs-testrpc Docker solution.

  2. Build the testrpc Docker image from source and start testrpc.
    • Type: mkdir ~/tools
    • Type: cd ~/tools
    • Type: git clone https://github.com/ethereumjs/testrpc.git
    • Type: cd testrpc
    • Type: docker build -t ethereumjs/testrpc .
    • Type: docker run -d -p 8545:8545 ethereumjs/testrpc:latest

  3. The docker container ethereumjs/testrpc:latest is now running.
    Testrpc is listening on localhost:8545
    Each time you start testrpc, 10 random Ethereum accounts are created.
    These accounts are unlocked.
    The first account is always the coinbase account.

  4. Check out tutorial How to setup a simple web interface using ethereum/web3.js to make JSON-RPC api calls to http://localhost:8545