Skip to content

GReturn/Project-Token42

Repository files navigation

Token42 Logo

Token42

Decentralized AI Dating Platform on Polkadot

Verifiable Identity Β· Private AI Matching Β· Staked Connections

Solidity TypeScript React Hardhat Polkadot Phala DevContainer


πŸ“– Overview

Token42 is a next-generation dating platform that solves the "Trust Gap" in online dating. By combining Polkadot's verifiable identity infrastructure with AI-powered matching inside secure enclaves, Token42 ensures that every user is a real human, every match is privately computed, and every interaction is economically accountable.

The name represents the search for the ultimate connection in a verifiable, tokenized world.


πŸš€ Key Features

Feature Description
πŸͺͺ Verifiable Identity Connect with real humans verified via Polkadot's People Chain identity infrastructure.
πŸ€– Private AI Matching Private personality analysis inside Phala Network's secure enclaves (TEE).
πŸ’° Staked Messaging Anti-spam protocol using rUSD staking to ensure high-value connections.
🏷️ Soulbound Profiles Non-transferable digital identities on the Revive EVM (PolkaVM).
πŸ›‘οΈ AI Moderation Oracle Automated harassment detection with on-chain slashing penalties

πŸ—οΈ Architecture

Token42 is built on a four-layer decentralized stack:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       FRONTEND (React/Vite)                 β”‚
β”‚         Wallet Connection Β· Profile UI Β· Chat Interface     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚    IDENTITY       β”‚    β”‚      INTELLIGENCE           β”‚   β”‚
β”‚  β”‚  People Chain     β”‚    β”‚  Phala Network TEE          β”‚   β”‚
β”‚  β”‚  (DID / Precomp.) β”‚    β”‚  Llama-3-8B Vectorization   β”‚   β”‚
β”‚  β”‚  0x...901         β”‚    β”‚  Cosine Similarity Matching β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  Match Intent Signing       β”‚   β”‚
β”‚           β”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚           β–Ό                             β–Ό                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚               LOGIC LAYER (Revive EVM)               β”‚   β”‚
β”‚  β”‚  Token42Profile.sol      Token42Messaging.sol        β”‚   β”‚
β”‚  β”‚  β€’ Soulbound Tokens      β€’ rUSD Staking              β”‚   β”‚
β”‚  β”‚  β€’ Identity Checks       β€’ Signature Verification    β”‚   β”‚
β”‚  β”‚  β€’ CID Storage           β€’ Slashing Oracle           β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                             β–Ό                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚            STORAGE LAYER (IPFS / Pinata)             β”‚   β”‚
β”‚  β”‚  Encrypted bios Β· Profile media Β· Metadata CIDs      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ XMTP V3 Messaging Flow (MLS)

Token42 uses XMTP V3 (MLS) for real-time, end-to-end encrypted messaging. Unlike legacy V2, V3 uses a "Group" architecture for all DMs, relying on a Welcome protocol and a local encrypted database (OPFS).

sequenceDiagram
    participant A as User A (Sender)
    participant N as XMTP Network (Nodes)
    participant B as User B (Receiver)
    participant DB as Local DB (OPFS)

    Note over A: 1. createDm(B_Addr)
    A->>N: Fetch B's Inbox ID
    A->>N: Publish MLS Welcome + Keys
    A->>N: Send Encrypted Message Packet
    
    Note over B: 2. Background sync()
    B->>N: Query for new Welcomes
    N-->>B: Return Welcome Packet
    Note over B: 3. Decrypt Welcome
    B->>DB: Store Group Keys

    Note over B: 4. Message stream()
    B->>N: Fetch Encrypted Packets
    N-->>B: Return Packets
    Note over B: 5. Decrypt Message (using keys from DB)
    B->>B: Resolve Sender Wallet Address
    Note over B: 6. Update UI
Loading

🧰 Technology Stack

Layer Technology Purpose
Smart Contracts Solidity 0.8.28, Minimal impls (no OZ), Hardhat Profile SBTs, staked messaging, slashing
Runtime Polkadot Asset Hub (Revive EVM / PolkaVM) EVM-compatible execution on Polkadot
Identity Paseo People Chain, Identity Precompile (0x...901) On-chain human verification (DID)
AI Engine Phala Network TEE, Llama-3-8B Private personality vectorization & matching
Storage IPFS (Pinata) Decentralized media & metadata hosting
Frontend React 18, TypeScript, Vite, ethers.js Mobile-responsive dApp interface
Wallets SubWallet, Talisman, MetaMask Transaction signing & identity proofs
Testing Hardhat (npx hardhat test) Contract unit & integration tests
Dev Env DevContainers, Kitdot CLI Zero-config development environment

πŸ“‚ Project Structure

token42/
β”œβ”€β”€ .devcontainer/               # DevContainer setup (Docker + VS Code)
β”‚   β”œβ”€β”€ devcontainer.json
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── scripts/                 # Setup & initialization scripts
β”œβ”€β”€ contracts/                   # Hardhat-compatible (Solidity ^0.8.28, no OZ)
β”‚   β”œβ”€β”€ contracts/               # Source files
β”‚   β”‚   β”œβ”€β”€ Token42Profile.sol   # Minimal soulbound profile
β”‚   β”‚   β”œβ”€β”€ Token42Messaging.sol # Minimal staked messaging
β”‚   β”‚   β”œβ”€β”€ MockRUSD.sol         # Test mock ERC-20
β”‚   β”‚   └── MockIdentityPrecompile.sol
β”œβ”€β”€ ignition/modules/            # Hardhat Ignition deployment
β”‚   └── Token42Module.js
β”œβ”€β”€ test/                        # Hardhat tests
β”‚   β”œβ”€β”€ Token42Profile.test.js
β”‚   └── Token42Messaging.test.js
β”œβ”€β”€ agent/                       # Phala TEE AI Agent
β”‚   └── src/index.ts             # Express server & AI logic
β”œβ”€β”€ frontend/                    # React dApp (Vite)
β”œβ”€β”€ guides/                      # Comprehensive Documentation
β”‚   β”œβ”€β”€ AGENTS.md                # AI agent instructions
β”‚   β”œβ”€β”€ AI_INTEGRATION_GUIDE.md  # Technical bridge between AI and contracts
β”‚   β”œβ”€β”€ KITDOT_HACKATHON_GUIDE.md # Development guide
β”‚   β”œβ”€β”€ LOCAL_INFERENCE.md       # Running Llama 3 locally via Ollama
β”‚   β”œβ”€β”€ LOCAL_TESTING_GUIDE.md   # 2-User interaction walkthrough
β”‚   └── UI_INTEGRATION_GUIDE.md  # Identity & Messaging UI requirements
β”œβ”€β”€ hardhat.config.js            # Hardhat + PolkaVM config
β”œβ”€β”€ .gitignore
└── README.md

πŸ› οΈ Onboarding & Installation

Prerequisites: Node.js 22+ and npm, Ollama (for local AI matching), or Docker for DevContainers.

Option A: DevContainer (RECOMMENDED)

  1. Install Docker Desktop and the VS Code Dev Containers extension
  2. Open this project in VS Code
  3. Click "Reopen in Container" β€” all tools install automatically

Option B: Manual Setup

git clone https://github.com/GReturn/Project-Token42.git
cd Project-Token42

1. Smart Contracts

npm install
npx hardhat compile
npx hardhat test

2. AI Agent (Local Matching)

Ensure Ollama is running and you have pulled the model: ollama pull llama3.

cd agent
npm install
# Configure .env with your AGENT_PRIVATE_KEY
npx tsx src/index.ts

3. Frontend

cd frontend
npm install
npm run dev

πŸš€ Deployment Status (Paseo Asset Hub)

The contracts are live on the Paseo Asset Hub (Revive EVM):

  • Token42Profile: 0x9B9f7569A535Cd2B66EC9B2F5509F5e688Ba92B5
  • Token42Messaging: 0x8B8d13a7f678FA8f6793290Ee9e46302Be427453
  • Token42Escrow: 0xb6B64176CC8a8350AB84D466CD4bf111C3A6E7a5
  • MockRUSD: 0xFE4eae5d84412B70b1f04b3F78351a654D28Da25 (with faucet() function)

πŸ“– Related Documentation

For deeper technical dives, see the following guides:


⚠️ Hackathon Prototype Caveats

Important

This version of Token42 is a Hackathon Prototype. To facilitate the demonstration, the following elements are currently simplified or mocked:

  1. Mock Data: The frontend initially populates some state with mock profile data to show the UI without waiting for IPFS/Contract indexing.
  2. Identity Simulation: The People Chain identity check is simulated in the UI; in production, this calls the 0x...901 precompile via a staticcall.
  3. Storage: Integration with Pinata (IPFS) is functional, but currently uses a public gateway for demonstration.
  4. Slashing: The moderation /slash endpoint is exposed for developers but not yet triggered by an automated on-chain oracle.

πŸ”„ User Flow

Connect Wallet  ──►  Verify Identity  ──►  Mint SBT Profile  ──►  AI Matching  ──►  Stake & Chat
     β”‚                    β”‚                      β”‚                     β”‚                  β”‚
  SubWallet /         People Chain           Token42Profile       Phala TEE Agent    Token42Messaging
  Talisman            Precompile 0x901       (Soulbound)         Cosine Similarity   rUSD Lock/Claim

🌍 SDG Alignment

SDG Impact
SDG 5 β€” Gender Equality AI moderation + staking reduces harassment; economic penalties deter bad actors
SDG 16 β€” Peace, Justice & Strong Institutions Sovereign decentralized identity; no central authority owns your data

About

Decentralized AI Dating Platform on Polkadot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors