Skip to content

A decentralized blockchain platform with a C++ core and JavaScript API layer, providing a peer-to-peer ledger system with REST API endpoints. Ideal for learning blockchain concepts and development, currently optimized for local networks over WiFi.

License

Notifications You must be signed in to change notification settings

Aradhya2708/blockshare

Repository files navigation

BlockShare

Open in Visual Studio Code Contributors Forks Stars License Node.js Version C++ Version

A Local Blockchain Network for Learning and Experimentation

Key FeaturesInstallationDocumentationContributing

🌟 Overview

BlockShare is a decentralized ledger and blockchain platform designed for running your own cryptocurrency in a local network environment. With a C++ core handling blockchain operations and a JavaScript-based API layer for client interactions, BlockShare provides a functional peer-to-peer network that supports transaction processing, balance management, and digital signature verification.

🚀 Key Features

  • 🌐 Local Cryptocurrency Network: Launch and manage a cryptocurrency network within a local WiFi environment.
  • 🔄 Peer-to-Peer Node Communication: Supports decentralized networking for nodes to communicate, process transactions, and maintain data consistency.
  • 🔒 Secure Transactions: Handles transaction signing and validation with digital signature verification.
  • 🛠️ RESTful API for Client Interactions: Offers API endpoints for network participation, transaction submissions, and balance inquiries.
  • 💰 Balance Management: Track individual account balances and total network balance.

⚠️ Note: BlockShare is intended for local network setups and educational purposes, not for deployment on public networks. It's a valuable resource for anyone wanting a hands-on approach to learning blockchain principles and creating a small-scale cryptocurrency.

📋 Prerequisites

  • Node.js (v14 or higher)
  • C++ Compiler (supporting C++11 or higher)
  • npm or yarn package manager
  • Machine with WinSock2 support for network operations

🔧 Installation

Step-by-step guide
  1. Clone the repository:
git clone https://github.com/Aradhya2708blockshare.git
cd blockshare
  1. Install Node.js dependencies:
npm install
  1. Compile C++ components:
# Compile main blockchain implementation
g++ blockchain.cpp -o blockchain -lws2_32

# Compile hash nonce utility
g++ hashNonce.cpp -o hashNonce

🖥️ Running a Node

  1. Create .env with IP and PORT

  2. Start the Node.js server:

npm run dev
  1. Execute the blockchain core:
./blockchain
  1. Add peer information in /localdb/peers.json

📡 API Endpoints for Client

Here’s how you can interact with your local BlockShare via REST API

🤝 Join Network

Allow a new node to join the local network by specifying the desired port.

# say one of the nodes in the local network is running over 172.12.345.678:3000
curl -X POST http://172.12.345.678:3000/blockchain/contribute \
  -H "Content-Type: application/json" \
  -d '{
    "provided_port": 8080,
  }'

💸 Submit Transaction

Submit a transaction, including details like sender, recipient, amount, nonce, and a signature.

curl -X POST http://172.12.345.678:3000/blockchain/submit-txn \
  -H "Content-Type: application/json" \
  -d '{
    "sender": "sender_address",
    "recipient": "recipient_address",
    "amt": 100,
    "nonce": 12345,
    "sign": "transaction_signature"
  }'

💰 Get Total Balance

Retrieve the total balance across the network.

curl http://172.12.345.678:3000/blockchain/balance

👤 Get Account Balance

Get the balance for a specific account address.

curl http://172.12.345.678:3000/blockchain/balance/0x123...abc

📊 Sample Response Formats

Balance Response

A typical balance response structure.

{
  "account": "0x123...abc",
  "balance": 1000
}

🤝 Contributing

  1. Fork the repository to start working on your changes.
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request to merge your changes.

About

A decentralized blockchain platform with a C++ core and JavaScript API layer, providing a peer-to-peer ledger system with REST API endpoints. Ideal for learning blockchain concepts and development, currently optimized for local networks over WiFi.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •