Fully fledged PoW blockchain implementation in TypeScript.
- Proof of Work (similar to Bitcoin's Hashcash)
- Consensus (similar to Bitcoin's longest chain)
- Implemented Node P2P communication via HTTP/S (register, transaction, blocks)
- Addresses in RSA PEM 1024/2048 easily swapable with e.g. elliptic curves
- Transaction SHA256 signature validation
- SHA256 Block Hashes
- All node operations are call-able via HTTP API
- Chain backed to disk in nodes via SQLite3 easily swapable with a different backend
Requires Node.js > 8.x.x
and yarn (npm i -g yarn
).
yarn
yarn start
3 Node Network E2E Tests
yarn test:p2p
yarn test:consensus
-
GET /api/address/new
blocking operation -
POST /api/address/transactions/:address - {address}
-
POST /api/address/balance/:address - {address}
-
GET /api/blocks/last
-
POST /api/transaction/sign - {transaction, address, privateKey}
test endpoint -
POST /api/transactions/new - {sender, recipient, amount, payload, timestamp, signature}
GET /api/mine
blocking operationGET /api/nodes/resolve
POST /api/nodes/register - {nodes}
GET /api/peer/chain
p2p node endpointPOST /api/peer/transaction - {transaction}
p2p node endpointPOST /api/peer/block - {block}
p2p node endpoint
Apache License 2.0
- During conflict resolvation the servering node streams TransferInterface to the fetching client node, but currently the client node does not stream insert the blockchain.
- Currently the blockchain validation function is based on a full in memory process, to scale further this needs to either be chunked/streamed or based on a db process.
- The balance of a sender should be checked when a transaction is made and when such a transaction is received by another node via peer communcation (requires a single function call)
- Additional hardening might be needed in case of blocks that are mined at the exact same time
- Addresses should be switched to elliptic curves to generate and sign faster
- SQLite3 should be switched with a more scaleable database
- Nodes should constantly extend their known nodes, by asking for other registered nodes (easily implemented)