Skip to content

kayyueth/gnosis-credit-card

Repository files navigation

Demo Vid | Product Deck | Pitch Vid

Gnosis Credit Card

banner

Gnosis Credit Card enables self-custodial spending with pre-approved credit, driven by decentralized identity and on-chain reputation.

With SafeAuth social login, Aave-backed borrowing, and off-chain settlement, users enjoy a seamless credit experience β€” without compromising ownership or privacy.

πŸ”„ User Journey

graph

  • Sign In with Social Account

    • User logs in via SafeAuth and instantly creates a self-custodial Safe smart wallet.
  • Get a Credit Score

    • A mock identity system assigns a credit tier based on on-chain activity and reputation.
  • Deposit Collateral & Activate Credit

    • User deposits ETH, and the system borrows stablecoins using a mock Aave lending flow.
  • Spend Off-Chain

    • Users spend within their credit limit; each transaction is hashed off-chain using merkle tree.
  • Monthly Settlement

    • Users repay manually or via monthly auto-deduction from collateral.
  • Earn Rewards & Build Credit

    • After repayment, users receive token rewards and see their credit score adjust over time.

πŸš€ Key Features

1. Social Authentication

  • Built with Safe and Web3Auth's new SafeAuth system
  • Users can log in using social accounts (e.g., Google, Discord) without leaving the dApp
  • Instantly creates a Safe Smart Account as the user's credit wallet

2. Identity & Credit Scoring

  • Comprehensive DID (Decentralized Identity) integration (simulated)
  • On-chain data analysis for credit assessment
  • Gnosis Pay transaction history analysis
  • Five-tier credit rating system:
    • Different credit limits
    • Variable cashback rewards
    • Customized interest rates

3. Deposit & Lending

  • Aave V3 protocol integration (simulated)
  • Direct collateral deposit / funds borrow through the credit card interface
  • 50% Loan-to-Value (LTV) ratio
  • Real-time collateral management

4. Repayment System

  • Off-chain pre-payment system
  • Merkle tree-based transaction hashing
  • Credit limit-based spending authorization
  • Real-time transaction tracking

5. Settlement & Rewards

  • Monthly batch settlement of off-chain transactions
  • Automated cashback token distribution

πŸ› οΈ Technical Stack

  • Smart Contracts: Solidity, Hardhat, Ethers.js, Viem -> Includes mock lending contracts inspired by Aave v3 (real Aave integration planned).
  • Frontend: Next.js, TypeScript, React, Tailwind CSS, Radix UI
  • Authentication: Safe Core SDK, Safe Protocol Kit, Safe API Kit, SafeAuth (Safe x Web3Auth), RainbowKit
  • Identity: Mock credit scoring based on on-chain data (Ceramic-based DID integration planned)
  • Settlement: Off-chain Merkle tree batching (ZK proof integration planned)
  • Blockchain: Gnosis Chiado Testnet

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MetaMask wallet
  • Git
  • pnpm (recommended) or npm

Installation

  1. Clone the repository:
git clone https://github.com/kayyueth/gnosis-credit-card.git
cd gnosis-credit-card
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env.local

Required environment variables:

NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=your_web3auth_client_id
NEXT_PUBLIC_INFURA_KEY=your_infura_key
NEXT_PUBLIC_CHIADO_RPC_URL=https://rpc.chiadochain.net
NEXT_PUBLIC_MOCK_WSTETH_ADDRESS=0x9fa52f7c3a19a066a9b7f2EBCA4BC6340366518F
NEXT_PUBLIC_MOCK_USDC_ADDRESS=0x969A2c1c858DA82FB48627DF8f5726c1fE0a2e94
NEXT_PUBLIC_MOCK_EURE_ADDRESS=0x137e7a3c32993cD0c15dfDF3020875322da145cd
NEXT_PUBLIC_MOCK_LENDING_PROTOCOL=0xF1D00F6c7E7Fc7Eda00fCe95583b8d6DD4716572
NEXT_PUBLIC_GNO_POINTS=0x70630625dCc6FDb9EFD00466A47E7d3883E6F5d5
NEXT_PUBLIC_GNOSIS_CREDIT_CARD=0xd443055C84Eb7ed7134586ED4605B17072A1025f
  1. Start the development server:
pnpm dev

The application will be available at http://localhost:3000

Smart Contract Deployment

  1. Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup
  1. Deploy contracts to Chiado testnet:
cd contracts
forge build
forge script script/Deploy.s.sol:DeployScript --rpc-url $NEXT_PUBLIC_CHIADO_RPC_URL --broadcast

Testing

Run the test suite:

# Unit tests
pnpm test

# E2E tests
pnpm test:e2e

Building for Production

pnpm build

Docker Support

Build and run with Docker:

docker build -t gnosis-credit-card .
docker run -p 3000:3000 gnosis-credit-card

πŸ“Š Credit Formula

A trust layer that scores users across 3 weighted dimensions (each 0–100):

Dimension Weight Description
Financial Trustworthiness 40% DeFi activity, LTV, repayment, liquidation
DAO Participation 30% Snapshot voting, GNO staking, proposal involvement
Social Connectivity 30% Multisig partners, Gitcoin Passport, social proof
  • Total score = 0.4 Γ— Financial + 0.3 Γ— DAO + 0.3 Γ— Social
  • Credit score influences borrowing limit and loan parameters

πŸ’° Credit Tiers

Credit Tier Credit Score Credit Limit Cashback Reward Interest Rate (based on Aave rate)
S, Sovereign 800-1000 $15,000 3% 0.8x
A, Ally 650-799 $10,000 2% 1x
B, Basic 500-649 $5,000 1.5% 1.2x
C, Citizen 350-499 $3,000 1% 1.5x
D, Dormant 0-349 $1,000 0.5% 1.8x

πŸ“ˆ Future Developments

Phase 0: Make It Smooth

  • Implement lock(): Prevent users from withdrawing borrowed funds until their credit balance is fully repaid, ensuring proper settlement of obligations.
  • Implement liquidate(): Automatically trigger liquidation of collateral if the user's health factor drops below 1.2, protecting the protocol against bad debt.
  • Implement forceRepay(): If a user fails to repay by the end of the billing cycle, the protocol will automatically swap a portion of their collateral to settle the outstanding credit.

Phase 1: Make It Work

  • Integrate with Aave v3 on Gnosis Chain for actual lending and borrowing.
  • Integrate Gnosis Pay API for issuing payment credentials and settlement.
  • Connect Ceramic for decentralized identity (DID) management.
  • Merge Gnosis Pay DID data to improve credit scoring granularity.

Phase 2: Make It Better

Allow users to generate ZK proofs of spending:

  • Prove creditworthiness without revealing transaction details.
  • Optional submission to 3rd-party credit evaluators or lending markets.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

ETHLisbon Hackathon 1st Place Winner | Self-Custodial Credit Card Backed by Decentralized Identity

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors