Javascript based blockchain
Javascript based blockchain
npm i
npm run node_1
or
nodemon --watch dev -js dev/networkNode.js 3001 http://localhost:3001
check package.json for complete details
Fetches complete Blockchain.
URL : http://localhost:3001/blockchain
Method : GET
Data
{
"chain": [
{
"index": 1,
"timestamp": <number>,
"transactions": [],
"nonce": 100,
"hash": "0",
"previousBlockHash": "0"
},
...
],
"pendingTransactions": [
{
"amount": <number>,
"sender": <string>,
"recipient": <string>,
"transactionId": <string>
},
...
],
"currentNodeUrl": "http://localhost:3001",
"networkNodes":
[
<string>,
...
]
}
To create and broadcast new Transactions.
URL : http://localhost:3001/transaction/broadcast
Method : POST
Data constraints
{
"amount": <number>,
"sender": <string>,
"recipient": <string>
}
To mine a new block.
URL : http://localhost:3001/mine
Method : GET
Data
{
"note": "New block mined & broadcast successfully",
"block": {
<block>
}
}
To register and broadcast new node URL.
URL : http://localhost:3001/register-and-broadcast-node
Method : POST
Data constraints
{
"newNodeUrl":<string>
}
To register and broadcast new node URL.
URL : http://localhost:3001/consensus
Method : GET
Data
{
"note": "This chain has been replaced.",
"chain": [
<blockchain>
]
}