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 a simple web interface using ethereum/web3.js



Information
You need to have a running ethereum node, for example testrpc and a running webserver.

Operating system used
macOS 10.12 Sierra

Software prerequisites
Node.js


Procedure
  1. Make sure you have access to a running ethereum node, for example testrpc
    In this example i assume JSON-RPC api calls can be made to http://localhost:8545.

  2. There are several methods to apply JSON-RPC api calls to http://localhost:8545. Using:

    • Web interface using ethereum/web3.js
    • Node.js script using ethereum/web3.js

    Use a Node.js script to communicate with an Ethereum node
    • Install web3 module, type: npm install -g web3
      Version 0.19.0 is now installed.

      Note:
      To check which version you have installed, type: npm list -g --depth=0

    • Download the demonstration Node.js script: ethereum_example1.js.txt
      Modify it according to your situation.

    • Run this Node.js script: node ethereum_example1.js

    Use a web application to communicate with an Ethereum node
    • Go to the web3.js github page: https://github.com/ethereum/web3.js/releases, select a release and download the source code.
      Download the same source code version as the installed web3 node module (to make it consistent).

    • In the dist folder you will find the files: web3-light.min.js and web3.min.js.
      The file web3.min.js contains the Bignumber module (https://github.com/MikeMcl/bignumber.js) and web3-light.min.js does not.
      If you are not sure which one to use, just use web3.min.js.

    • Download the demonstration web application: ethereum_example1.html
      Modify it according to your situation.

    • Copy this html file to your webserver <docroot> and access this file in your browser:
      http://localhost:8545/ethereum_example1.html