This guide will help you set up the complete HydroFi system with blockchain integration for Green Hydrogen Credit tracking using ERC-1155 NFTs.
- Node.js (v16 or higher)
- MongoDB (running locally or connection string)
- Git
cd backend
npm install etherscd frontend
npm install etherscd contracts
npm install# Terminal 1 - Start local blockchain
cd contracts
npx hardhat node
# Terminal 2 - Deploy contract
cd contracts
npx hardhat run scripts/deploy.js --network localhost- Update
contracts/hardhat.config.jswith your network details - Add your private key to
backend/.env - Deploy:
npx hardhat run scripts/deploy.js --network <network_name>
cd backend
npm run devcd frontend
npm run dev- Generate Credits: Mint new ERC-1155 tokens representing hydrogen credits
- View Active Credits: See all minted tokens and their status
- Retire Credits: Burn tokens to prevent double-counting
- Factory Management: Track production by factory ID
- Portfolio View: See owned credits and their value
- Transfer Credits: Send tokens to other addresses
- Retirement: Retire owned credits
- Transaction History: View purchase and transfer history
- Complete Overview: See ALL tokens, transactions, and statistics
- Token Registry: Full searchable database of all credits
- Transaction Monitoring: Real-time view of all blockchain activity
- Compliance Tracking: Monitor system-wide metrics
- Advanced Analytics: Comprehensive statistics and reporting
- Verification Registry: View all verified tokens
- Facility Certification: Track certified production facilities
- Audit Trail: Complete verification history
- Quality Assurance: Token verification and compliance monitoring
- Token Standard: ERC-1155 (each token ID has supply of 1, making them NFT-like)
- Metadata: Immutable on-chain storage of credit details
- Functions:
mintToken(): Create new creditssafeTransferFrom(): Transfer creditsretireToken(): Burn creditsgetTokenMetadata(): Public verification
{
creator: address, // Producer's wallet
creationTimestamp: uint256, // When created
factoryId: string, // Production facility
currentOwner: address, // Current holder
lastTransferTimestamp: uint256,
isRetired: boolean, // Retirement status
retirementTimestamp: uint256,
retiredBy: address // Who retired it
}POST /api/auth/register- User registrationPOST /api/auth/login- User login
POST /api/blockchain/mint- Mint tokens (Producer only)POST /api/blockchain/transfer- Transfer tokensPOST /api/blockchain/retire- Retire tokensGET /api/blockchain/tokens- Get tokens by roleGET /api/blockchain/stats- System statistics (Admin only)GET /api/blockchain/transactions- Transaction history (Admin only)
- β Mint new tokens
- β View own tokens
- β Retire own tokens
- β Admin functions
- β View owned tokens
- β Transfer tokens
- β Retire owned tokens
- β Mint tokens
- β Admin functions
- β View ALL tokens and transactions
- β System statistics
- β Complete audit trail
- β Admin dashboard
- β Mint tokens (audit only)
- β View ALL tokens for verification
- β Facility certification tracking
- β Verification dashboard
- β Mint tokens
- β Admin statistics
PORT=5000
MONGODB_URI=mongodb://localhost:27017/hydrofi_db
JWT_SECRET=your_super_secret_jwt_key_here
# Blockchain Configuration
BLOCKCHAIN_RPC_URL=http://localhost:8545
WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
DEFAULT_WALLET_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266Create accounts for each role:
- Producer: Can mint credits
- Buyer: Can purchase/transfer credits
- Regulatory: Admin access to all data
- Certification: Verification access
- Login as Producer
- Go to Dashboard
- Enter Factory ID (e.g., "FACTORY-001")
- Click "Generate 5 Credits"
- Tokens are minted and visible in "My Active Credits"
- Login as Regulatory Authority
- View comprehensive dashboard with:
- All tokens across the system
- Real-time transaction history
- System-wide statistics
- Complete audit trail
- Login as Buyer
- View purchased tokens
- Transfer to other addresses
- Retire credits when used
- Error: "Contract data not found"
- Solution: Deploy the smart contract first using Hardhat
- Error: "Failed to connect to blockchain"
- Solution: Ensure local Hardhat node is running or update RPC URL
- Error: "Insufficient funds" or "Transaction reverted"
- Solution: Check wallet has ETH for gas fees (Hardhat provides test ETH)
- Error: "Access denied"
- Solution: Verify user role matches required permissions
For technical issues or questions:
- Check browser console for errors
- Verify all services are running
- Check environment variables
- Ensure MongoDB is connected
π Production Setup: For production deployment:
- Use secure private key management
- Deploy to mainnet or production testnet
- Implement proper access controls
- Use environment-specific configuration
- Testing: Use the system to mint, transfer, and retire credits
- Integration: Connect with real wallet providers (MetaMask)
- Scaling: Deploy to production blockchain networks
- Features: Add marketplace functionality, batch operations
- Analytics: Enhanced reporting and compliance features
HydroFi: Blockchain-Based Green Hydrogen Credit System Transparent β’ Immutable β’ Compliant