CrypChain is a modern, TypeScript-based blockchain implementation designed for educational purposes and real-world applications. It demonstrates core blockchain concepts while maintaining a clean, maintainable codebase.
Clone the repository
git clone https://github.com/iminoaru/CrypChain.git
Navigate to the project directory
cd CrypChain
Install the dependencies
npm install
Build the project
npm run build
Each block in CrypChain contains:
The mining process follows these steps:
CrypChain provides a RESTful API for interacting with the blockchain:
GET /blockchain
Returns the entire blockchain. Response includes block height, timestamp, and transaction count.
GET /transactions
Returns all pending transactions in the pool. Includes sender, recipient, amount, and timestamp.
GET /public-key
Returns the node's public key for receiving transactions.
GET /mine-transactions
Triggers the mining process for pending transactions.
GET /peers
Returns a list of connected peer nodes.
POST /mine
Mines a new block. Request body should include the block data.
{
"data": "Block data here"
}
POST /transfer
Creates a new transaction. Required fields:
{
"recipient": "public_key_here",
"amount": 100
}
To create a local test network, run multiple instances with different ports:
# Terminal 1 (Primary Node)
HTTP_PORT=3001 P2P_PORT=5001 npm run dev
# Terminal 2 (Secondary Node)
HTTP_PORT=3002 P2P_PORT=5002 PEERS=ws://localhost:5001 npm run dev
# Terminal 3 (Tertiary Node)
HTTP_PORT=3003 P2P_PORT=5003 PEERS=ws://localhost:5001,ws://localhost:5002 npm run dev
CrypChain implements a decentralized peer-to-peer network where each node:
Nodes discover peers through:
The project follows these conventions:
To contribute to CrypChain:
Verify firewall settings and port availability
Check system resources and difficulty adjustment
Ensure proper key pair generation and sufficient balance