This repository contains the smart contracts for the Lamda Network's hybrid-chain blockchain foundation. The system uses two distinct contracts deployed on different BNB Chain networks to handle specific responsibilities.
The Lamda Network implements a hybrid-chain approach with two main contracts:
-
NodeReputation.sol (opBNB Testnet)
- Provider directory and reputation management
- Optimized for frequent, low-cost updates
- Handles provider registration, heartbeats, and job completion tracking
-
JobManager.sol (BNB Smart Chain Testnet)
- Escrow agent for job payments
- Designed for security over cost
- Manages job creation, confirmation, and payment distribution
- Node.js (v16 or higher)
- npm or yarn
- A wallet with testnet BNB for deployment
- API keys for contract verification (optional)
npm install
Copy the example environment file and configure your settings:
cp env.example .env
Edit .env
and add your configuration:
# Deployer wallet private key (without 0x prefix)
DEPLOYER_PRIVATE_KEY=your_private_key_here
# API Keys for contract verification (optional)
BSCSCAN_API_KEY=your_bscscan_api_key_here
OPBNBSCAN_API_KEY=your_opbnbscan_api_key_here
# Optional: Enable gas reporting
REPORT_GAS=true
npm run compile
npm run deploy:reputation
npm run deploy:manager
Network: opBNB Testnet (Chain ID: 5611)
Purpose: Provider directory and reputation management
registerNode(string gpuModel, uint256 vram)
- Register a new providersendHeartbeat()
- Send periodic heartbeat to signal online statusincrementJobs(address provider)
- Increment provider's job count (admin only)getProviderInfo(address provider)
- Get provider informationisProviderActive(address provider)
- Check if provider is active
NodeRegistered(address indexed provider, string gpuModel, uint256 vram)
NodeHeartbeat(address indexed provider, uint256 timestamp)
JobCountIncremented(address indexed provider, uint256 newCount)
Network: BNB Smart Chain Testnet (Chain ID: 97)
Purpose: Job escrow and payment management
createJob(bytes32 jobId, address providerAddress)
- Create job and lock paymentconfirmResult(bytes32 jobId)
- Confirm job completion (renter only)claimReward(bytes32 jobId)
- Claim payment (provider only)getJobInfo(bytes32 jobId)
- Get detailed job informationgetJobStatistics()
- Get contract statistics
JobCreated(bytes32 indexed jobId, address indexed renter, address indexed provider, uint256 payment)
JobConfirmed(bytes32 indexed jobId, uint256 confirmedAt)
PaymentClaimed(bytes32 indexed jobId, address indexed provider, uint256 amount)
npm test
REPORT_GAS=true npm test
After deployment, contracts are automatically verified on their respective block explorers:
- NodeReputation: https://testnet.opbnbscan.com
- JobManager: https://testnet.bscscan.com
- OpenZeppelin
Ownable
for admin controls - Input validation for registration parameters
- Timestamp-based activity tracking
- OpenZeppelin
ReentrancyGuard
for payment functions - Comprehensive access control
- Double-spending prevention
- Secure payment handling with low-level calls
- RPC URL: https://opbnb-testnet-rpc.bnbchain.org/
- Chain ID: 5611
- Explorer: https://testnet.opbnbscan.com
- Currency: tBNB
- RPC URL: https://data-seed-prebsc-1-s1.bnbchain.org:8545/
- Chain ID: 97
- Explorer: https://testnet.bscscan.com
- Currency: tBNB
The contracts emit events that your off-chain backend services should monitor:
- Provider Registration: Monitor
NodeRegistered
events for new providers - Provider Activity: Monitor
NodeHeartbeat
events for provider status - Job Creation: Monitor
JobCreated
events for new job requests - Job Completion: Monitor
JobConfirmed
events for completed jobs - Payment Processing: Monitor
PaymentClaimed
events for payment confirmations
- Private Key Security: Never commit your
.env
file to version control - Testnet Usage: These contracts are configured for testnet deployment
- Gas Optimization: The contracts are optimized for their respective networks
- Event Monitoring: Ensure your backend services properly handle all emitted events
For questions or issues related to the smart contracts, please refer to the Lamda Network documentation or contact the development team.
This project is licensed under the MIT License - see the LICENSE file for details.