Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 1.57 KB

README.md

File metadata and controls

40 lines (34 loc) · 1.57 KB

Blockchain

A simple test blockchain and cryptocurrency implementation in JavaScript using express.

How to use?

  1. Clone the project using
    `git clone https://github.com/ashwinrisbood/Blockchain.git
  2. Install packages by running npm install
  3. Create Clients and join them as peers.
    • By default clients are created serving API on 3000 and p2p on 8000.
    • Create the first client by running npm start.
    • Create the second client by passing additional parameters for
      • HTTP_PORT = POrt to run the HTTP server
      • P2P_PORT = Port to run the P2p client
      • PEERS = comma separated address of Peers in P2p connection for example: HTTP_PORT=3001 P2P_PORT=8001 PEERS=block://localhost:8000 npm start
  4. Create API requests to run blockchain functions.

An example flow of blockchain operations

  • GET public key of one of the nodes using /public-key for example: GET localhost:3000/public-key
    Response: { "publicKey": "04b406d69697ecc5..." }

  • POST transactions from on of the clients to this address using /transact and providing { "recipient": "04b406d69697ecc5...", "amount": 50 }

  • Check transactions on any of the clients using GET /transactions

  • Mine the transaction using a client into the blockchain by calling GET on /mine-transactions.

NOTE: The client that Mines recieves a 50 unit crypto for his processing. this is visible in the blockchain that is returned in response to /mine-transactions.

Pending Feature additions:

  • dynamic add node