GithubHelp home page GithubHelp logo

innovator007 / crypto-chain Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 2.3 MB

Blockchain based cryptocurrency

JavaScript 95.29% HTML 0.66% CSS 4.05%
blockchain cryptocurrency cryptography sha256 elliptic nodejs express javascript es6 blockchain-backup p2p-port transaction-pool dapp

crypto-chain's Introduction

crypto-chain

To setup locally:

Open Terminal and paste in the following commands

git clone https://github.com/Innovator007/crypto-chain.git
cd crypto-chain/
npm install 
npm run test

After running all these commands on your machine blockchain can be created by running the development server:

Make sure you have nodemon installed if not install it by the following command:

npm install -g nodemon

Then run the following command to run the development http server on port 3001 and peer-to-peer server on port 5001

npm run dev

Now to test that the blockchain works perfectly and it synchronizes among different peers and follow the concept of decentralized applications.

Open up another terminal and now you have to set environment variables for this terminal and add following command in your terminal:

HTTP_PORT=3002 P2P_PORT=5002 PEERS=ws://localhost:5001 npm run dev

HTTP_PORT

It can be any other than the 3001

P2P_PORT

It can also be any other than 5001

PEERS

This defines all the peers you want to connect and it is of form ws://[localhost or ip]:P2P_PORT[,ws://[localhost or IP]:P2P_PORT]

You can now open as many terminals you want and follow the above procedure.

/blocks route: GET Request

Returns all the blocks in the chain.

/transactions route: GET Request

Returns all the transactions in the transaction pool which are unconfirmed and can only be confirmed after mining in which they are removed from the transaction pool.

/public-key route: GET Request

Returns the public-key or public-address of the user.

/balance route: GET Request

Returns the balance and public-key of the user.

/transact route: POST Request

Data to be sent in json form:

  • recipient: public-key or public-address of the reciever
  • amount: amount to be sent to the reciever

It adds the transaction in the transaction pool and synchronizes the transactions among its peers.

/mine-transactions route: GET Request

This is the most powerful and uses compulational resources to mine the transactions and make them confirmed and add in the block in the blockchain

Test all these routes via POSTMAN or any other http request maker like POSTMAN.

crypto-chain's People

Contributors

innovator007 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

dhruvbabariya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.