Smart contracts for the CurrentDao solar energy ecosystem on Stellar/Soroban.
This project contains comprehensive smart contracts for energy trading:
- Energy Token ($WATT) - A custom token representing 1kWh of energy
- Energy Trading Escrow - Secure escrow system for energy trades with dispute resolution
- DAO Contract - Allows members to vote on where to build new solar arrays
- Security & Access Control - Comprehensive security framework
- Fee Management - Dynamic fee system for network operations
- Emergency Systems - Emergency response and recovery mechanisms
We've implemented a comprehensive Energy Trading Escrow System that provides:
- Multi-party Escrow: Buyer, seller, and mediator roles
- Time-based Auto-release: Automatic token release after 48 hours
- Dispute Resolution: Admin arbitration with penalty system
- Milestone Trading: Partial releases for milestone-based deliveries
- Emergency Recovery: Multi-signature emergency release mechanisms
- Comprehensive Audit Trail: Complete transaction history tracking
- Security Protection: Reentrancy guards, rate limiting, input validation
- Gas Optimization: Efficient batch operations
# Deploy the escrow system
npm run deploy:escrow development
# Run tests
npm run test:escrow
# View documentation
cat docs/escrow/EnergyEscrow.mdCurrentDao-contracts/
├── Cargo.toml # Workspace configuration
├── contracts/
│ ├── token/ # Energy Token ($WATT) contract
│ │ ├── Cargo.toml
│ │ └── src/
│ │ └── lib.rs
│ ├── escrow/ # Escrow contract
│ │ ├── Cargo.toml
│ │ └── src/
│ │ └── lib.rs
│ └── dao/ # DAO contract
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
└── README.md
- Rust (1.70 or later)
- Soroban CLI (
cargo install stellar-soroban-cli)
To build all contracts:
cargo build --target wasm32-unknown-unknown --releaseThe compiled WASM files are in:
target/wasm32-unknown-unknown/release/energy_token.wasmtarget/wasm32-unknown-unknown/release/escrow_contract.wasmtarget/wasm32-unknown-unknown/release/dao_contract.wasm
The Energy Token represents 1kWh of energy and is used to track energy contributions from solar panel installations.
Functions:
initialize(admin, decimals, name, symbol)- Initialize the tokenmint(to, amount)- Mint new tokenstransfer(from, to, amount)- Transfer tokensbalance(addr)- Get token balanceset_admin(new_admin)- Set adminburn(from, amount)- Burn tokens
The Escrow contract holds payments from contributors until the smart meter confirms energy delivery.
Functions:
initialize(admin)- Initialize escrowcreate_escrow(sender, recipient, amount)- Create new escrowconfirm_delivery(escrow_id)- Confirm delivery, release fundscancel_escrow(escrow_id)- Cancel escrowget_escrow(escrow_id)- Get escrow details
The DAO allows members to propose and vote on where to build new solar arrays.
Functions:
initialize(admin, token_address)- Initialize DAOcreate_proposal(proposer, location, description, amount)- Create proposalvote(voter, proposal_id, support)- Vote on proposalfinalize(proposal_id)- Finalize proposalget_proposal(id)- Get proposal details
- Deploy the Energy Token contract first
- Deploy the Escrow contract
- Deploy the DAO contract with the token address
- Contributors receive $WATT tokens (representing their energy contribution)
- DAO members vote on proposals for new solar installations
- Escrow ensures payments are held until energy delivery is confirmed