Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

VoltXchange - Decentralized Energy Trading Platform

A Web3 platform for peer-to-peer renewable energy trading built on the Stellar blockchain with Soroban smart contracts.

Overview

VoltXchange enables direct energy trading between producers and consumers using blockchain technology, smart contracts, and IoT integration. Energy producers can tokenize their renewable energy output as tradable "sparks" tokens, while consumers can purchase energy directly from the grid.

Architecture

Smart Contracts (Soroban/Rust)

  • EnergyToken: ERC-20 compatible token representing energy credits
  • TradeEngine: P2P escrow system for energy trades
  • MeterOracle: IoT data validation and token minting

Frontend (React/TypeScript)

  • Live Grid Map visualization
  • Usage Dashboard with real-time analytics
  • Trading Interface for P2P energy exchange
  • Wallet integration with Stellar

Backend Infrastructure

  • IoT Bridge: MQTT/CoAP gateway for meter data
  • Price Aggregator: Real-time energy price feeds

Quick Start

Prerequisites

  • Node.js 18+
  • Rust 1.70+
  • Soroban CLI
  • Docker (for IPFS)

Installation

  1. Clone the repository
git clone <repository-url>
cd VoltXchange
  1. Install frontend dependencies
cd frontend
npm install
  1. Install backend dependencies
cd ../backend
npm install
  1. Build smart contracts
cd ../contracts
cargo build --target wasm32-unknown-unknown --release

Configuration

Create .env files in each service directory:

Frontend (.env)

REACT_APP_STELLAR_NETWORK=testnet
REACT_APP_CONTRACT_ADDRESS=<contract-address>

Backend (.env)

STELLAR_NETWORK=testnet
ORACLE_CONTRACT_ID=<oracle-contract>
ENERGY_TOKEN_CONTRACT_ID=<token-contract>
ORACLE_SECRET_KEY=<oracle-secret>
MQTT_BROKER_URL=mqtt://localhost:1883

Running the Platform

  1. Start IPFS node
ipfs daemon
  1. Deploy smart contracts
cd contracts
soroban contract deploy EnergyToken.wasm --network testnet
soroban contract deploy TradeEngine.wasm --network testnet
soroban contract deploy MeterOracle.wasm --network testnet
  1. Start backend services
cd backend
npm run iot-bridge
npm run price-aggregator
  1. Start frontend
cd frontend
npm start

Smart Contract Details

EnergyToken

  • Purpose: Tokenize renewable energy production
  • Features: Mint/burn, oracle authorization, metadata
  • Symbol: SPARK

TradeEngine

  • Purpose: Facilitate P2P energy trades
  • Features: Escrow, fee handling, trade lifecycle
  • Fee: 0.5% per trade

MeterOracle

  • Purpose: Validate IoT meter data
  • Features: Reading submission, confirmation, frequency optimization
  • Key Wave Task: Optimizes oracle call frequency based on network conditions

Frontend Components

Live Grid Map

  • Real-time visualization of energy producers/consumers
  • Interactive grid with location-based trading
  • Supply/demand indicators

Usage Dashboard

  • Energy production/consumption analytics
  • Token balance tracking
  • Trading history

Trading Interface

  • Market view with current prices
  • Trade creation and management
  • Order book visualization

Backend Services

IoT Bridge

  • MQTT Support: Standard IoT protocol
  • CoAP Support: Low-power device protocol
  • Stellar Integration: On-chain data submission

Price Aggregator

  • Multiple Sources: EIA, ENTSO-E, market data
  • Real-time Updates: 5-minute intervals
  • Forecasting: 24-hour price predictions

API Documentation

IoT Bridge API

  • GET /health - Service health check
  • GET /api/meters - Get recent readings
  • POST /api/meters/:meterId/reading - Submit reading

Price Aggregator API

  • GET /api/prices/current - Current prices
  • GET /api/prices/history - Historical data
  • GET /api/prices/forecast - Price predictions

Development

Testing

# Frontend tests
cd frontend && npm test

# Backend tests
cd backend && npm test

# Contract tests
cd contracts && cargo test

Code Quality

# Linting
npm run lint

# Formatting
cargo fmt

Deployment

Smart Contracts

# Deploy to testnet
soroban contract deploy --network testnet --source <account>

# Deploy to mainnet
soroban contract deploy --network public --source <account>

Frontend

# Build for production
npm run build

# Deploy to Vercel/Netlify
vercel --prod

Backend

# Build TypeScript
npm run build

# Deploy with Docker
docker build -t voltxchange-backend .
docker run -p 3001:3001 voltxchange-backend

Security Considerations

  • Oracle keys stored securely
  • Multi-signature for critical operations
  • Rate limiting on APIs
  • Input validation and sanitization

Monitoring

  • Health endpoints on all services
  • Prometheus metrics integration
  • Structured logging with Winston
  • Error tracking and alerting

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Implement changes with tests
  4. Submit pull request

License

MIT License - see LICENSE file for details.

Support

Roadmap

  • Mobile app development
  • Advanced AI price prediction
  • Cross-chain compatibility
  • Grid integration partnerships
  • Carbon credit integration

About

Energy Trading Platform: A decentralized grid where renewable energy producers can sell "sparks" (tokenized kWh) directly to neighbors.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages