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.

A simple nodejs script using ethereum/web3.js making JSON-RPC api calls

You need to have a running ethereum node, for example testrpc

Operating system used
macOS 10.12 Sierra

Software prerequisites

  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.

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

    In both cases you need to install the following node packages:
    • Install web3, type: npm install -g web3
      Version 0.19.0 is now installed.

    • Install big-number.js, type: npm install -g bignumber.js
      Version 4.0.2 is now installed.
      This package is required by web3.

  3. Download the nodejs file: ethereum_example1.js
    Modify it according to your situation and rename this file to ethereum_example1.js

  4. To execute this file, type: node ethereum_example1.js