🧠 Use Case::

Build a decentralized microloan platform for underserved small businesses.

Smallholder farmers, women-led cooperatives, and informal vendors often lack access to traditional financial services. This PoC enables credential-based microloans, with VC-anchored eligibility, Aiken smart contracts for disbursement/repayment, and clear Cardano-native tooling for frontend + on-chain coordination.

1. 🧩 Functional Flow (Cardano-Compatible)

[Borrower Onboards]

↓

[VC Issued (Eligibility, KYC, Score)]

↓

[VC Hash Anchored in CIP-68 NFT (optional)]

↓

[Loan Contract Deployed w/ Terms]

↓

[Loan Claimed Manually → Funds Sent]

↓

[Manual Repayment via Wallet TX]

↓

[NGO Reviews Loan Status via Dashboard]

2. 🧾 Credential Schema – vc-schema/msme-eligibility.json

Field Description
type Type of VC (e.g. MSMEEligibility)
issuer DID of issuing NGO
credentialSubject.name Borrower's legal name
businessType Informal sector classification
location Region or city
incomeBracket Self-reported or verified income
eligibilityScore A simple float between 0–1
{

"@context": ["<https://www.w3.org/2018/credentials/v1>"],

"type": ["VerifiableCredential", "MSMEEligibility"],

"issuer": "did:cardano:ngo123",

"issuanceDate": "2025-08-01T00:00:00Z",

"credentialSubject": {

"id": "did:cardano:user789",

"name": "Ama Diarra",

"businessType": "Agriculture",

"location": "Bauchi, Nigeria",

"incomeBracket": "USD 200-400/mo",

"eligibilityScore": 0.72

},

"proof": {

"type": "Ed25519Signature2020",

"created": "2025-08-01T01:00:00Z",

"proofPurpose": "assertionMethod",

"verificationMethod": "did:cardano:ngo123#key-1",

"jws": "eyJhbGciOiJFZERTQSJ9..."

}


3. 🔐 CredentialSubject Hashing Script

📁 utils/hash.ts

import { createHash } from 'crypto'

export function hashCredentialSubject(input: object): string {

const canonical = JSON.stringify(input)

return createHash('sha256').update(canonical).digest('hex')

}

// Example usage

const subject = {

name: "Ama Diarra",

businessType: "Agriculture",

location: "Bauchi, Nigeria",

incomeBracket: "USD 200-400/mo",

eligibilityScore: 0.72

}

console.log("VC Hash:", hashCredentialSubject(subject))

4. 📜 Smart Contract Logic (Aiken) – contracts/loan_repayment.aiken

// Validate that the VC used is one of the authorized hashes

fn validate_eligibility(vc_hash: ByteArray, expected_hash: ByteArray) -> Bool {

vc_hash == expected_hash

}

// Validate repayment meets deadline and minimum repayment

fn validate_repayment(due_date: Int, amount: Int, paid_on: Int) -> Bool {

paid_on <= due_date && amount >= 1000000 // min 1 ADA

}

// Combine checks for loan claim

fn main(

submitted_hash: ByteArray,

expected_hash: ByteArray,

amount: Int,

due_date: Int,

paid_on: Int

) -> Bool {

validate_eligibility(submitted_hash, expected_hash)

&& validate_repayment(due_date, amount, paid_on)

}

🔒 Smart contracts only validate — the borrower must manually submit loan claim and repayment TXs.

5. 🧰 Tools & Libraries

Layer Toolset Description
VC Issuance CLI or NGO form-based UI Create JSON-LD VC + Ed25519 signature
Hashing js-sha256, hash.ts Calculate VC hash to anchor on-chain
On-Chain Logic Aiken Validator for loan claim + repayment TX
Frontend Mesh SDK + Lucid Evolution Wallet connect, TX builder, status dashboard
Wallets Eternl / Lace / Typhon / PWA Borrower interface to claim and repay loans
APIs Koios / Blockfrost Fetch TX status, repayment status
Storage IPFS VC backup, signed loan agreements (optional)