https://github.com/ac12644/blockchain
Create Blockchain With NodeJs🚀
https://github.com/ac12644/blockchain
blockchain cli crypto-js discovery-swarm ecdsa falcon512 leveldb nodejs peer2peer proof-of-stake proof-of-work wallet
Last synced: about 2 months ago
JSON representation
Create Blockchain With NodeJs🚀
- Host: GitHub
- URL: https://github.com/ac12644/blockchain
- Owner: ac12644
- License: mit
- Created: 2022-04-10T01:02:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-25T20:30:13.000Z (3 months ago)
- Last Synced: 2025-06-25T21:31:43.233Z (3 months ago)
- Topics: blockchain, cli, crypto-js, discovery-swarm, ecdsa, falcon512, leveldb, nodejs, peer2peer, proof-of-stake, proof-of-work, wallet
- Language: JavaScript
- Homepage:
- Size: 170 KB
- Stars: 20
- Watchers: 2
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Blockchain
A modular educational blockchain built in Node.js.
Switch consensus (PoW/PoS) and cryptography (secp256k1/Falcon PQC) on the fly.
Read the Medium article »
⭐ Star this repo if you like real, hackable blockchain code!
---
## Features
- Modular **P2P blockchain network**
- Pluggable **consensus**: Proof-of-Work (PoW) or Proof-of-Stake (PoS)
- Pluggable **cryptography**: Classic (secp256k1) or **Post-Quantum** (Falcon-512)
- Automatic **fork detection** and **chain re-org**
- Educational **wallet** and **transaction** system (works with any crypto mode)
- Syncs with peers, broadcasts blocks, and supports miner registration
- CLI and REST API for block, wallet, and chain interaction---
## Steps Implemented
- Creating a basic P2P network
- Sending and receiving blocks
- Registering miners and creating new blocks
- Setting up a name-value database (LevelDB/RocksDB)
- Creating a private-public wallet with pluggable crypto
- REST API for chain/wallet interaction
- Command-line interface
- Consensus switch (PoW / PoS)
- Cryptography switch (secp256k1 / Falcon PQC)
- Automatic fork detection and chain re-org
---
## Getting Started
```sh
npm install
```## Usage
### Run in Default Mode (PoW, secp256k1):
```sh
node p2p.js```
Switch Consensus (PoW / PoS):
```sh
npm run start:pow # Proof-of-Work (default)
npm run start:pos # Proof-of-Stake
```Or with environment variable:
```sh
CONSENSUS_MODE=pow node p2p.js
CONSENSUS_MODE=pos node p2p.js
```Switch Cryptography (secp256k1 / Falcon Post-Quantum):
```sh
npm run start:secp # Classic ECDSA (default)
npm run start:falcon # Falcon-512 (Post-Quantum, requires pqclean)
```Or with environment variable:
```sh
CRYPTO_MODE=secp256k1 node p2p.js
CRYPTO_MODE=falcon node p2p.js
```You can combine switches:
```sh
CRYPTO_MODE=falcon CONSENSUS_MODE=pos node p2p.js
```### Advanced
- Run multiple nodes: Use multiple terminals, each in a separate folder, or clear /wallet before launching to simulate multiple identities.
- Fork detection/re-org: Disconnect peers and create different blocks, then reconnect to see automatic chain resolution.
- Stake management: Edit stake values in code for PoS testing.
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request