A revolutionary DeFi lending protocol on Hedera Hashgraph that rewards borrowers for contributing to verified sustainability projects. Built on Hedera's carbon-negative network.
- Lending & Borrowing: Deposit HBAR to earn interest or borrow against collateral
- Carbon Credit NFTs: Earn verified carbon offset NFTs through Guardian integration
- Dynamic Interest Rates: Reduce your borrowing costs by up to 50% through carbon offsets
- Gamified Leaderboard: Compete to be a top climate champion
- Climate Fund Vault: Stake HBAR to support sustainability initiatives
- Telegram Notifications: Real-time updates on NFTs, interest rates, and rankings
- Blockchain: Hedera Hashgraph (EVM)
- Smart Contracts: Solidity with Hardhat
- Frontend: Next.js + TypeScript + Tailwind CSS
- Backend: Node.js + Express
- Database: Firebase
- Verification: Hedera Guardian Framework
- Wallet: HashPack / MetaMask
- Notifications: Telegram Bot API
greendefi/
├── contracts/ # Solidity smart contracts
│ ├── LendingPool.sol
│ ├── GreenRewardManager.sol
│ ├── InterestRateModel.sol
│ ├── ClimateFundVault.sol
│ ├── LeaderboardTracker.sol
│ └── interfaces/
├── backend/ # Node.js backend services
│ └── src/
│ ├── server.js
│ └── services/
│ ├── guardianOracle.js
│ ├── telegramBot.js
│ ├── mirrorNodeListener.js
│ └── firebaseService.js
├── frontend/ # Next.js frontend
│ ├── app/
│ ├── components/
│ ├── contexts/
│ └── lib/
└── scripts/ # Deployment scripts
└── deploy.js
- Node.js 18+
- npm or yarn
- Hedera testnet account
- Firebase project
- Telegram bot token
-
Clone the repository
git clone https://github.com/TYDev01/Green-Defi-Lending-Protocol.git cd greendefi -
Install root dependencies
npm install
-
Install frontend dependencies
cd frontend npm install -
Install backend dependencies
cd ../backend npm install
-
Create environment files
Root
.env:HEDERA_TESTNET_RPC=https://testnet.hashio.io/api PRIVATE_KEY=your_private_key OPERATOR_ID=0.0.xxxxx OPERATOR_KEY=your_operator_keyBackend
.env:GUARDIAN_API_URL=https://guardian-api-url GUARDIAN_API_KEY=your_guardian_api_key FIREBASE_API_KEY=your_firebase_api_key FIREBASE_PROJECT_ID=your_project_id TELEGRAM_BOT_TOKEN=your_telegram_bot_token MIRROR_NODE_URL=https://testnet.mirrornode.hedera.comFrontend
.env.local:NEXT_PUBLIC_HEDERA_RPC=https://testnet.hashio.io/api NEXT_PUBLIC_API_URL=http://localhost:3001
-
Compile contracts
npm run compile
-
Deploy contracts to Hedera testnet
npx hardhat run scripts/deploy.js --network hedera_testnet
-
Update environment files with deployed contract addresses
-
Start the backend
cd backend npm start -
Start the frontend
cd frontend npm run dev -
Access the application Open http://localhost:3000
- Manages deposits, borrows, and repayments
- Integrates with InterestRateModel for dynamic rates
- Applies green discounts via GreenRewardManager
- Mints carbon credit NFTs verified by Guardian
- Tracks user green profiles and carbon offsets
- Calculates interest rate adjustments (up to 50% reduction)
- Manages NFT retirement for permanent impact
- Implements kinked interest rate model
- Adjusts rates based on pool utilization
- Base rate: 2%, Multiplier: 10%, Jump: 100%, Kink: 80%
- Staking mechanism for climate project funding
- 8% APY on staked HBAR
- Direct funding of verified sustainability projects
- Ranks users by total carbon offset
- Awards badges: Eco Starter, Green Champion, Climate Hero, Earth Guardian
- Provides rank multipliers for additional rewards
The protocol integrates with Hedera Guardian for:
- Verification: Carbon credit verification through Guardian APIs
- NFT Minting: Automated NFT creation upon verification
- Data Integrity: Guardian Verifiable Credentials (VCs)
- Project Tracking: Link NFTs to specific sustainability projects
GET /api/leaderboard- Get top contributorsGET /api/user/:address- Get user profileGET /api/stats- Get protocol statisticsGET /api/guardian/verification/:id- Get verification statusPOST /api/telegram/subscribe- Subscribe to notifications
/start- Initialize bot and view commands/subscribe <wallet>- Subscribe to notifications/unsubscribe- Unsubscribe from notifications/status- Check subscription status/leaderboard- View top contributors/stats- View protocol statistics
# Run contract tests
npm test
# Run frontend tests
cd frontend
npm test
# Run backend tests
cd backend
npm test- ReentrancyGuard on all state-changing functions
- Access control with Ownable
- Input validation and bounds checking
- Safe math operations with Solidity 0.8+
- WARNING: Audit recommended before mainnet deployment
- Core lending protocol
- Guardian integration
- Carbon credit NFTs
- Dynamic interest rates
- Telegram notifications
- Gamified leaderboard
- Multi-token support (USDC, USDT)
- Farcaster miniapp integration.
- Governance token (GREEN)
- DAO governance
- Mainnet deployment
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT License
- Hedera Hashgraph team
- Guardian Framework contributors
- OpenZeppelin for secure contract libraries
- The DeFi and ReFi communities