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
It can be any other than the 3001
It can also be any other than 5001
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]
Returns all the blocks in the chain.
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.
Returns the public-key or public-address of the user.
Returns the balance and public-key of the user.
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.
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.