A revolutionary DeFi platform combining multi-wallet portfolio analysis, referral-based credit scoring, and real Flare FDC Web2JSON integration for comprehensive credit assessment.
CredChain solves DeFi's biggest credit assessment problem by introducing:
- ๐ฆ Multi-Wallet Portfolio Analysis: Aggregate credit scores across all user wallets
- ๐ค Referral-Based Credit Network: Social trust scoring with chain-based reward propagation
- ๐ Real Flare FDC Integration: Authentic Web2-to-Web3 credit data bridging
- โ๏ธ Intelligent Composite Scoring: 70% off-chain + 30% aggregated on-chain scoring
graph TB
A[User Registration] --> B[Multi-Wallet Linking]
B --> C[On-Chain Score Aggregation]
C --> D[Off-Chain Score via FDC]
D --> E[Referral Network Analysis]
E --> F[Composite Credit Score]
F --> G[Lending Decision]
H[Referral System] --> I[Chain-Based Rewards]
I --> J[Social Trust Scoring]
J --> E
K[Smart Contracts] --> L[ReferralCreditNetwork.sol]
K --> M[CreditScoreOracle.sol]
N[The Graph] --> O[Referral Network Indexing]
O --> P[Subgraph Queries]
Frontend:
- React 18 + TypeScript
- Next.js 15 with Turbopack
- Tailwind CSS for modern UI
- ethers.js v5 for blockchain interaction
Backend:
- Node.js + Express.js
- Real Flare FDC Web2JSON integration
- JWT authentication
- IPFS/decentralized storage
Blockchain:
- Solidity smart contracts
- Hardhat development environment
- OpenZeppelin security standards
- The Graph protocol for indexing
Infrastructure:
- MetaMask wallet integration
- Local Hardhat network for development
- Comprehensive test suites
- Node.js 16+
- MetaMask browser extension
- Git
# Clone the repository
git clone <your-repo-url>
cd hackathon-project
# Install dependencies
npm install
# Start local blockchain (Terminal 1)
npx hardhat node
# Deploy contracts (Terminal 2)
node scripts/deployReferralContract.js
# Start backend (Terminal 3)
cd backend && PORT=8080 npm start
# Start frontend (Terminal 4)
cd frontend && npm run devAdd Local Network:
- Network Name:
Hardhat Local - RPC URL:
http://127.0.0.1:8545 - Chain ID:
1337 - Currency Symbol:
ETH
Import Demo Accounts:
- Account #0:
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 - Private Key:
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Users can link multiple wallets representing different crypto activities:
- DeFi Trading Wallet: High-risk, high-reward activities
- Savings Wallet: Conservative, long-term holdings
- NFT Wallet: Digital asset collections
- Gaming Wallet: Play-to-earn activities
Intelligent Aggregation:
// Example: User with 3 wallets
Wallet 1: 750 (Excellent)
Wallet 2: 650 (Good)
Wallet 3: 400 (Poor)
โ Aggregated Score: 600 (Weighted average)Chain-Based Reward Propagation:
- If X refers Y, and Y refers Z
- When Z improves credit by 5 points:
- Z's score: +5 points
- Y's referral score: +1 point
- X's referral score: +0.001 points
Multi-Path Rewards:
- If X refers both Y and A, and both refer Z
- When Z improves credit:
- Both Y and A get +1 point each
- X gets +0.002 points (rewards accumulate)
On-Chain Approval System:
- Users refer others via email
- Referrals must be accepted on-chain
- All relationships stored on blockchain
- Tracked via unique Web3 IDs
Authentic Implementation:
- Follows official Flare documentation
- Cryptographic proofs with Merkle trees
- ABI-encoded responses for smart contracts
- Real attestation IDs and verification
Credit Data Flow:
Traditional Credit Bureau โ FDC Web2JSON โ Smart Contract โ DeFi Protocol
Subgraph Schema:
- User entities with referral relationships
- Credit events and score changes
- Referral rewards and penalties
- Network statistics and analytics
- Daily/weekly aggregations
Real-Time Indexing:
- All referral events indexed automatically
- Complex queries for referral paths
- Network statistics and metrics
- User referral history
- Real smart contract interactions
- MetaMask transaction signing
- On-chain referral relationships
- Gas fees required
- Mock data for presentations
- Instant interactions
- Pre-configured scenarios
- Perfect for hackathon demos
Toggle between modes in the dashboard:
// Frontend component
<button onClick={() => setUseDemoMode(!useDemoMode)}>
{useDemoMode ? 'Switch to Live Mode' : 'Switch to Demo Mode'}
</button># Backend tests
cd backend
# Test multi-wallet portfolio
node test/testMultiWalletPortfolio.js
# Test FDC Web2JSON integration
node test/testFDCWeb2Json.js
# Test referral system
node test/testReferralSystem.js
# Verify composite scoring
node test/verifyCompositeScore.js
# Live demonstration
node test/demonstrateScoreGeneration.js# Deploy and test contracts
npx hardhat test
# Test referral functionality
node test-referral-system.js
# Verify on-chain scoring
node test/verifyOnChainScoring.js| Endpoint | Method | Description |
|---|---|---|
/api/portfolio/register |
POST | Register new user with Web3 ID |
/api/portfolio/link-wallet |
POST | Link wallet to user portfolio |
/api/portfolio/scores |
GET | Get composite credit scores |
/api/credit-score/fdc/attest |
POST | FDC Web2JSON attestation |
/api/referral/create |
POST | Create referral request |
/api/referral/accept |
POST | Accept referral invitation |
Register User:
curl -X POST http://localhost:8080/api/portfolio/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"walletAddress": "0x742d35Cc6634C0532925a3b8D4C9d1E6b0Db1d46"
}'Link Additional Wallet:
curl -X POST http://localhost:8080/api/portfolio/link-wallet \
-H "Content-Type: application/json" \
-d '{
"walletAddress": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
}'Get Credit Scores:
curl -X GET http://localhost:8080/api/portfolio/scores \
-H "Authorization: Bearer <jwt-token>"Opening Hook (30 seconds): "Traditional DeFi only sees one wallet per user, but real users have multiple wallets for different activities. CredChain solves this with the first multi-wallet portfolio analysis system, combined with authentic Flare FDC Web2JSON integration and referral-based social credit scoring."
Live Demo Flow (4 minutes):
- User Registration โ Show Web3 ID generation
- Link Wallet 1 โ Score: 750 (Excellent DeFi trader)
- Link Wallet 2 โ Portfolio: 690 (Conservative saver added)
- Link Wallet 3 โ Portfolio: 620 (Risky NFT wallet brings down average)
- Set Off-Chain Score โ FDC Web2JSON integration (820 traditional credit)
- Create Referral โ Demonstrate on-chain referral system
- Final Composite โ 744 (excellent lending candidate)
Technical Validation (30 seconds):
- Show FDC Response with real attestation IDs
- Show smart contract interactions in MetaMask
- Show referral relationships on blockchain
Innovation:
- First multi-wallet portfolio analysis in DeFi
- Real user behavior modeling (multiple wallets)
- Social trust scoring via referral networks
Technical Excellence:
- Real Flare FDC Web2JSON (not mock)
- Complete smart contract implementation
- The Graph protocol integration
- Production-ready architecture
Market Impact:
- Addresses $50B+ DeFi lending market
- Bridges TradFi and DeFi credit assessment
- Enables lending for users with limited crypto history
Backend (.env):
PORT=8080
NODE_ENV=development
# Flare Network
FLARE_RPC_URL=https://flare-api.flare.network/ext/bc/C/rpc
FLARE_NETWORK_ID=14
# FDC Configuration
FDC_ATTESTATION_URL=https://fdc-api.flare.network
FDC_API_KEY=your_fdc_api_key_here
# JWT Secret
JWT_SECRET=your_jwt_secret_hereFrontend (.env.local):
NEXT_PUBLIC_REFERRAL_CONTRACT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545Primary Circle Configuration:
- File:
backend/config.js - Lines 24-27: Circle API configuration and base URL setup
Environment Setup:
- File:
README.md(this file) - Lines 203-205: Circle API environment variables documentation
Authentication Integration:
- File:
backend/services/userAuthService.js - Lines 45-67: Circle-based user verification and wallet linking
- Multi-wallet portfolio analysis
- Real Flare FDC Web2JSON integration
- Basic referral system
- Smart contract deployment
- The Graph subgraph deployment
- Advanced referral reward algorithms
- Cross-chain portfolio analysis
- Mobile app development
- Mainnet deployment
- Real credit bureau integrations
- Institutional lending partnerships
- Security audits and optimization
- First multi-wallet portfolio analysis in DeFi lending
- Novel referral-based credit scoring with chain propagation
- Real-world problem solving for DeFi credit assessment
- Authentic Flare FDC integration (not mock)
- Complete smart contract system with security standards
- The Graph protocol implementation for complex queries
- Production-ready architecture with comprehensive testing
- Beautiful, modern UI with Tailwind CSS
- Live score progression as wallets are linked
- Intuitive referral system with email invitations
- Mobile-responsive design for all devices
- Addresses $50B+ DeFi lending market
- Production-quality implementation ready for deployment
- Bridge between TradFi and DeFi credit systems
- Scalable architecture for millions of users
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Flare Network for FDC Web2JSON technology
- The Graph for decentralized indexing
- OpenZeppelin for secure smart contract standards
- Hardhat for development framework
- MetaMask for wallet integration