Code targeted on blockchain implementation in JavaScript
Consensus: PoW/PoS with longest chain
Hash: SHA256
Nodes: Variable
Block Size: Variable (Default: 5)
- Nodejs (Used: v16.15.1)
- NPM (Used: v8.11.0)
- POSTMAN to interact with API (2022 June)
- Required modules/libraries
- Express (Used: v4.18.1)
- Nodemon (Used: v1.19.4)
- Body-parser (Used: v1.20.0)
- Request-promise (Used: v4.2.6)(Deprecated)
- SHA256 (Used: v0.2.0)
- UUID (Used: v3.4.0)
- (GET) View Existing Blockchain http://localhost:3001/blockchain
- (POST) Create Transaction broadcast http://localhost:3001/transaction/broadcast
- (POST) Create Multiple Transactions broadcast http://localhost:3001/multiple-txn
- (POST) Register and Broadcast Nodes http://localhost:3001/register-and-broadcast-node
- (GET) Mine blocks broadcast using PoW http://localhost:3001/mine
- (POST) Mine blocks broadcast using PoS http://localhost:3001/mine-pos
- (POST) Mine blocks in all LBCs using PoS http://localhost:3001/multi-mine
- (GET) Invoke Consensus and Blockchain Sync http://localhost:3001/consensus
- (GET) View Global blockchain http://localhost:3009/bridge
This repo contains all iterations for personal convenience. The latest release and step-by-step documentation to use the code and reproduce results is available here . Please keep in mind that this code is only for simulation of the hierarchical model and performance testing, hence does not implement several features that commercial blockchains do.
- Remember to set TRANSACTION_THRESHOLD in both files to alter block size.
- Change node count by opening the API on different ports. Check package.json to define additional nodes. Remember to declare these in the network during register-and-broadcast-node
- When running /mine-pos endpoint remember to input number of nodes. Mandatory for working of PoS.
- This code does not implement wallets (PKI/signing), ICO and validator lists.