A trustless, AI-verified marketplace for trading datasets as NFTs on Polkadot's Westend Asset Hub
- Overview
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- Smart Contracts
- Backend Services
- Frontend Application
- AI Verification
- Deployment
- Contributing
Devra revolutionizes data trading by combining blockchain technology, AI verification, and decentralized storage to create a transparent marketplace where:
- Datasets are NFTs: Immutable ownership proof on Polkadot
- AI Quality Assurance: Automated verification before minting
- Encrypted Storage: IPFS-based decentralized storage with encryption
- Trustless Trading: Smart contract-powered peer-to-peer transactions
- Fair Pricing: Dynamic marketplace with transparent price discovery
β¨ NFT-Based Ownership - Every dataset is an ERC-721 token
π€ AI Verification - Quality scoring and authenticity checks
π End-to-End Encryption - RSA encryption before IPFS upload
π Integrated Marketplace - List, buy, and cancel listings on-chain
π Multi-Format Support - CSV, JSON, ZIP, Parquet, Excel
π¨ Modern UI/UX - Cyberpunk-inspired, responsive design
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β β’ React 19 + Server Components β
β β’ Wagmi v2 + Viem (Web3) β
β β’ Framer Motion (Animations) β
β β’ Tailwind CSS v4 β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
β RPC Calls (Viem)
β
ββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ
β Smart Contract (Solidity 0.8.28) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β DatasetNFT.sol β β
β β β’ ERC-721 Implementation β β
β β β’ mint(cid, score) β β
β β β’ list(tokenId, price) β β
β β β’ buy(tokenId) β β
β β β’ cancelListing(tokenId) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β Deployed on Westend Asset Hub β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
β Events & Queries
β
ββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ
β Backend (NestJS + Python) β
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β NestJS API Server β β AI Verifier (FastAPI)β β
β β β’ Upload Handler ββββββββΊβ β’ Quality Analysis β β
β β β’ Encryption Svc β β β’ Fraud Detection β β
β β β’ IPFS Integration β β β’ Scoring Engine β β
β β β’ BullMQ Jobs β β β’ ML Models β β
β ββββββββββββ¬βββββββββββ βββββββββββββββββββββββ β
β β β
β ββββββββββββΌβββββββββββ βββββββββββββββββββββββ β
β β PostgreSQL β β Redis (BullMQ) β β
β β (Prisma ORM) β β (Job Queue) β β
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
β Upload Encrypted Data
β
ββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ
β IPFS (Decentralized Storage) β
β β’ Content-Addressed Storage (CIDs) β
β β’ Encrypted Dataset Files β
β β’ Metadata & Verification Reports β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-
Upload Flow
User β Frontend β Backend β AI Verifier β Encryption β IPFS β Get CID β User β Frontend β Smart Contract β Mint NFT β Return CID βββββββ -
Purchase Flow
Buyer β Frontend β Smart Contract.buy() β Transfer Funds β Transfer NFT β Buyer β IPFS β Decrypt β Access Grant β Event Listener -
Listing Flow
Owner β Frontend β Smart Contract.list() β Set Price β Emit ListingCreated
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 15.5.5 | React framework with App Router |
| React | 19.1.0 | UI library with Server Components |
| TypeScript | 5.x | Type-safe development |
| Tailwind CSS | 4.0 | Utility-first styling |
| Wagmi | 2.19.2 | React hooks for Ethereum |
| Viem | 2.38.6 | TypeScript Ethereum library |
| Framer Motion | 12.23.24 | Animation library |
| TanStack Query | 5.90.7 | Data fetching & caching |
| Lucide React | 0.545.0 | Icon library |
| Technology | Version | Purpose |
|---|---|---|
| NestJS | 11.0.1 | Node.js framework |
| Prisma | 6.17.1 | ORM for PostgreSQL |
| BullMQ | 5.61.0 | Job queue with Redis |
| PostgreSQL | 8.x | Relational database |
| Redis | IORedis 5.8.1 | In-memory cache & queue |
| Axios | 1.12.2 | HTTP client |
| Technology | Version | Purpose |
|---|---|---|
| FastAPI | Latest | High-performance API framework |
| PyTorch | Latest | Deep learning framework |
| Transformers | Latest | NLP models (BERT, DistilBERT) |
| Sentence-Transformers | Latest | Semantic similarity |
| Pandas | Latest | Data analysis |
| Scikit-learn | Latest | ML utilities |
| Pillow | Latest | Image processing |
| Technology | Version | Purpose |
|---|---|---|
| Solidity | 0.8.28 | Smart contract language |
| Polkadot | Asset Hub | EVM-compatible blockchain |
| IPFS | HTTP Client | Decentralized storage |
| Ethers.js | 6.15.0 | Ethereum library (scripts) |
Devra/
βββ devra-frontend/ # Next.js 15 Frontend
β βββ app/
β β βββ components/ # Reusable UI components
β β β βββ Hero.tsx
β β β βββ Navbar.tsx
β β β βββ Footer.tsx
β β β βββ About.tsx
β β βββ animations/ # Framer Motion animations
β β βββ connect/ # Wallet connection page
β β βββ marketplace/ # Dataset marketplace
β β βββ datasets/ # User datasets management
β β βββ dashboard/ # User dashboard
β β βββ providers.tsx # Wagmi & React Query setup
β βββ lib/
β β βββ wagmi.ts # Web3 configuration
β β βββ contracts/ # Contract interaction hooks
β β βββ useDataset.ts # NFT contract hooks
β β βββ DatasetNFT.ts # Contract ABI & config
β βββ hooks/
β β βββ useWallet.ts # Wallet connection hook
β β βββ useContract.ts # Generic contract hook
β βββ package.json
β
βββ devra-backend/ # NestJS Backend
β βββ src/
β β βββ modules/
β β β βββ upload/ # File upload handling
β β β βββ encryption/ # RSA encryption service
β β β βββ verification/ # AI verification integration
β β β βββ crust/ # IPFS/Crust integration
β β β βββ prisma/ # Database service
β β βββ common/
β β β βββ config/ # Redis & Vault config
β β βββ main.ts
β βββ prisma/
β β βββ schema.prisma # Database schema
β βββ package.json
β
βββ devra-ai_verifier/ # Python AI Service
β βββ main.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ Procfile # Deployment config
β
βββ devra-contracts/ # Solidity Smart Contracts
β βββ contracts/
β β βββ DatasetNFT.sol # Main NFT contract
β βββ scripts/ # Deployment scripts
β β βββ deploy_with_ethers.ts
β β βββ deploy_with_web3.ts
β βββ tests/ # Contract tests
β
βββ README.md # This file
- Node.js 20.x or higher
- npm or yarn
- Python 3.10+
- PostgreSQL 14+
- Redis 7+
- MetaMask or Talisman wallet
git clone https://github.com/Nebulaz7/Devra.git
cd Devracd devra-frontend
npm install
cp .env.example .env.local
# Configure your environment variables
npm run dev
# Open http://localhost:3000Environment Variables (.env.local)
NEXT_PUBLIC_CONTRACT_ADDRESS=0x25e485fc5492ce1c65cfd438de6d64eb62335cd7
NEXT_PUBLIC_CHAIN_ID=420420421
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000cd devra-backend
npm install
cp .env.example .env
# Configure database and Redis
npx prisma migrate dev
npm run start:dev
# Backend runs on http://localhost:3000Environment Variables (.env)
DATABASE_URL="postgresql://user:password@localhost:5432/devra"
REDIS_HOST=localhost
REDIS_PORT=6379
AI_VERIFIER_URL=http://localhost:5000/
IPFS_GATEWAY=https://ipfs.iocd devra-ai_verifier
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload --port 5000
# AI service runs on http://localhost:5000/cd devra-backend
npx prisma migrate dev --name init
npx prisma generateDeployed Address: 0x25e485fc5492ce1c65cfd438de6d64eb62335cd7
Network: Westend Asset Hub (Chain ID: 420420421)
Explorer: Blockscout
// Mint a new dataset NFT
function mint(bytes32 cid, uint8 score) external returns (uint256)
// List dataset for sale
function list(uint256 tokenId, uint96 price) external
// Purchase a listed dataset
function buy(uint256 tokenId) external payable
// Cancel listing
function cancelListing(uint256 tokenId) external
// Get dataset info
function datasetInfo(uint256 tokenId) external view returns (Data memory)event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
event ListingCreated(uint256 indexed tokenId, uint96 price)
event ListingCancelled(uint256 indexed tokenId)
event Sold(uint256 indexed tokenId, address indexed buyer, uint96 price)cd devra-contracts
npm install
# Deploy using Remix IDE or:
npx hardhat run scripts/deploy_with_ethers.ts --network westendHandles multipart file uploads with validation.
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
async uploadDataset(
@UploadedFile() file: Express.Multer.File,
@Body() dto: CreateDatasetDto
) {
// 1. Validate file
// 2. Send to AI verifier
// 3. Encrypt file
// 4. Upload to IPFS
// 5. Return CID
}RSA-based encryption for dataset security.
async encryptFile(buffer: Buffer, publicKey: string): Promise<Buffer> {
// AES-256-GCM encryption with RSA-wrapped keys
}Background job processing for uploads.
@Process('upload-dataset')
async processUpload(job: Job) {
// 1. Verify with AI
// 2. Encrypt data
// 3. Upload to IPFS
// 4. Update database
}// lib/wagmi.ts
import { createConfig, http } from "wagmi";
import { westendAssetHub } from "./chains";
import { metaMask } from "@wagmi/connectors";
export const config = createConfig({
chains: [westendAssetHub],
connectors: [metaMask()],
transports: {
[westendAssetHub.id]: http(),
},
});// lib/contracts/useDataset.ts
export function useMintDataset() {
const { writeContractAsync } = useWriteContract();
const mint = async (cid: string) => {
const hash = await writeContractAsync({
address: CONTRACT_ADDRESS,
abi: DatasetNFTABI,
functionName: "mint",
args: [cid, 85], // CID and quality score
});
return hash;
};
return { mint };
}- Hero.tsx - Landing page hero section with 3D animations
- Navbar.tsx - Navigation with wallet connection
- Marketplace.tsx - Dataset browsing and purchasing
- Datasets.tsx - User's owned datasets management
- MintDatasetModal.tsx - Multi-step minting workflow
@app.post("/verify")
async def verify_dataset(file: UploadFile):
# 1. Extract and parse data
data = extract_data(file)
# 2. Quality metrics
completeness = calculate_completeness(data)
consistency = check_consistency(data)
# 3. Fraud detection
duplicates = detect_duplicates(data)
anomalies = find_anomalies(data)
# 4. AI scoring
score = ml_quality_score(data)
return {
"score": score,
"quality_metrics": {...},
"fraud_indicators": {...}
}- BERT - Text quality analysis
- DistilBERT - Fast text classification
- ResNet18 - Image dataset verification
- Sentence-BERT - Semantic similarity
cd devra-frontend
vercel deploy --prodBuild Configuration:
{
"buildCommand": "npm run build",
"outputDirectory": ".next",
"framework": "nextjs"
}cd devra-backend
# Set environment variables
railway up# render.yaml
services:
- type: web
name: devra-ai-verifier
env: python
buildCommand: pip install -r requirements.txt
startCommand: uvicorn main:app --host 0.0.0.0 --port $PORTUse managed services:
- Supabase (Recommended)
- Railway
- Render
cd devra-frontend
npm run testcd devra-backend
npm run test
npm run test:e2ecd devra-contracts
npm run testWe welcome contributions! Please follow these steps:
- 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
- Frontend: ESLint + Prettier
- Backend: NestJS style guide
- Contracts: Solidity style guide
- Live Demo: https://devra.vercel.app
- Contract Explorer: View on Blockscout
Built with β€οΈ by the Devra Team
Making data trading fair, transparent, and decentralized