A fully decentralized lending platform built on Ethereum. Users can borrow stablecoins (DUSD) by locking ETH as collateral. The system features a Soulbound Reputation System that dynamically optimizes capital efficiency for trusted borrowers. It integrates real-world price feeds via a custom Oracle Bridge, uses IPFS for immutable metadata storage, and employs Automated Keeper Bots to ensure protocol solvency.
- Backend: Hardhat, Solidity, OpenZeppelin
- Frontend: Next.js, TypeScript, Tailwind CSS, Shadcn UI
- Integration: Wagmi, Viem
- Key Features:
- ERC-20 Stablecoin Implementation
- Chainlink Oracle Integration (Mocked for Demo)
- Cryptographic hashing of loan agreements
- Dynamic Collateral Ratios based on History
- IPFS with Pinata
- Loans given for a duration
- Node.js (v18 or higher)
- MetaMask Wallet (Browser Extension)
- Git
- Pinata
Clone the repository and install dependencies for both the backend and frontend.
# Using the helper script
./setup.sh
# OR Manual Installation
cd backend && npm install
cd ../frontend && npm installThis project uses Pinata for decentralized IPFS storage. You must configure your API keys to upload loan metadata.
- cd frontend
- cp .env.example .env.local
- Get your API Keys from Pinata Dashboard and fill the file:
NEXT_PUBLIC_PINATA_API_KEY=your_api_key NEXT_PUBLIC_PINATA_SECRET_API_KEY=your_secret_key NEXT_PUBLIC_PINATA_GATEWAY=gateway.pinata.cloud
Running a full-stack DApp requires two separate terminal windows running simultaneously.
Start the local Hardhat network. This acts as your local Ethereum blockchain server.
cd backend
npx hardhat nodeKeep this terminal open. It will show transaction logs and gas usage.
Deploy the smart contracts and launch the user interface.
# Using the helper script (Assumes Terminal 1 is running)
./run.sh
# OR Manual Execution
# 1. Deploy contracts (Auto-updates frontend config)
cd backend
npx hardhat run scripts/deploy.ts --network localhost
# 2. Start Frontend
cd ../frontend
npm run devcd backend
npx hardhat run scripts/bot.ts --network localhostOpen http://localhost:3000 in your browser.
- Open MetaMask settings.
- Add a Network Manually:
- RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH
- RPC URL:
- Import Accounts:
- In Terminal 1, Hardhat prints 20 accounts with private keys.
- Import Account #0 (The Deployer/Borrower).
- Import Account #1 (The Lender).
- Connect Account #0.
- Navigate to the Borrow tab.
- Request
100DUSD. - Confirm the transaction. You will see your ETH balance decrease (Collateral locked).
- Switch to Account #1.
- Navigate to the Lend tab.
- Click "Get 1000 Test DUSD" (Wait for balance update).
- Approve and Fund the loan request.
To demonstrate the safety features of the smart contract:
- Scroll down to the Admin / Demo Controls.
- Manually change the Mock ETH Price from
2000to100. - Click Update Oracle.
- Click Liquidate on the active loan.
- Explain: The contract detected under-collateralization and allowed the liquidation to secure the platform's solvency.
my-lending-dapp/
├── backend/
│ ├── contracts/ # Solidity Smart Contracts
│ ├── scripts/ # Deployment & Config Gen Scripts
│ └── hardhat.config.ts
├── frontend/
│ ├── src/app/ # Next.js Pages
│ ├── src/components/ # UI Components
│ └── src/lib/ # Constants.ts (Auto-generated)
├── setup.sh # Installation Helper
└── run.sh # Execution Helper