Skip to content

WJWaldock/toxchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ToxChain - Decentralized Toxicity Prediction Platform

🧬 Overview

ToxChain is a Web3 + AI platform that enables pharmaceutical companies to contribute toxicity data anonymously, trains ML models on aggregated data, and rewards contributors via smart contracts. This decentralized approach solves the data sharing problem in drug development while maintaining privacy and incentivizing participation.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Smart         β”‚    β”‚   ML API        β”‚
β”‚   (Next.js)     │◄──►│   Contracts     │◄──►│   (FastAPI)     β”‚
β”‚                 β”‚    β”‚   (Solidity)    β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   RainbowKit    β”‚    β”‚   Ethereum/     β”‚    β”‚   PostgreSQL    β”‚
β”‚   + wagmi       β”‚    β”‚   Arbitrum      β”‚    β”‚   + IPFS        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and pnpm
  • Python 3.10+
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/toxchain/toxchain.git
cd toxchain
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
# Copy example files
cp frontend/env.example frontend/.env.local
cp contracts/env.example contracts/.env
cp ml-api/env.example ml-api/.env
  1. Deploy the stack:
# Development deployment
./scripts/deploy.sh localhost development

# Production deployment to testnet
./scripts/deploy.sh sepolia production

Access Points

πŸ“ Project Structure

toxchain/
β”œβ”€β”€ frontend/               # Next.js 14 application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/           # App Router pages
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ hooks/         # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ store/         # Zustand state management
β”‚   β”‚   └── lib/           # Utility functions
β”‚   └── package.json
β”œβ”€β”€ contracts/             # Smart contracts
β”‚   β”œβ”€β”€ contracts/         # Solidity contracts
β”‚   β”œβ”€β”€ test/             # Contract tests
β”‚   β”œβ”€β”€ scripts/          # Deployment scripts
β”‚   └── hardhat.config.ts
β”œβ”€β”€ ml-api/               # Python ML API
β”‚   β”œβ”€β”€ app/              # FastAPI application
β”‚   β”œβ”€β”€ models/           # ML model files
β”‚   β”œβ”€β”€ data/             # Training data
β”‚   └── requirements.txt
β”œβ”€β”€ scripts/              # Deployment utilities
β”œβ”€β”€ docs/                 # Documentation
└── package.json          # Root package.json

πŸ”§ Development

Frontend Development

cd frontend
pnpm dev

Smart Contract Development

cd contracts
pnpm compile
pnpm test
pnpm deploy:localhost

ML API Development

cd ml-api
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload

πŸ§ͺ Testing

Run All Tests

# Frontend tests
cd frontend && pnpm test

# Smart contract tests
cd contracts && pnpm test

# ML API tests
cd ml-api && pytest

End-to-End Testing

# Start all services
./scripts/deploy.sh localhost development

# Run E2E tests
cd frontend && pnpm test:e2e

πŸš€ Deployment

Local Development

./scripts/deploy.sh localhost development

Testnet Deployment

# Deploy to Arbitrum Sepolia
./scripts/deploy.sh arbitrum-sepolia production

# Deploy to Ethereum Sepolia
./scripts/deploy.sh sepolia production

Production Deployment

  1. Smart Contracts: Deploy to Arbitrum One
  2. ML API: Deploy to Railway/Render
  3. Frontend: Deploy to Vercel

πŸ“Š Features

Core Features

  • βœ… Data Contribution: Submit toxicity data with SMILES validation
  • βœ… AI Prediction: Real-time toxicity prediction with confidence scores
  • βœ… Reward System: Token rewards based on data quality and model improvement
  • βœ… Leaderboard: Gamified contributor rankings
  • βœ… Privacy: Anonymous data submission with IPFS storage

Advanced Features

  • πŸ”„ Model Retraining: Automatic model updates with new data
  • πŸ“ˆ Analytics Dashboard: Model performance and contribution metrics
  • πŸ† Reputation System: Contributor validation accuracy tracking
  • πŸ” Access Control: Pay-per-use data access for pharmaceutical companies

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS + shadcn/ui
  • Web3: wagmi + RainbowKit + viem
  • State: Zustand + TanStack Query
  • Charts: Recharts

Smart Contracts

  • Language: Solidity 0.8.24
  • Framework: Hardhat
  • Libraries: OpenZeppelin
  • Networks: Ethereum, Arbitrum

ML API

  • Framework: FastAPI
  • Language: Python 3.11
  • ML: PyTorch + Transformers
  • Database: PostgreSQL + Redis
  • Chemistry: RDKit

πŸ“ˆ Performance

  • Prediction Latency: < 200ms average
  • Model Accuracy: 88% on DILIrank dataset
  • Gas Costs: ~$0.50 per contribution
  • Uptime: 99.9% target

πŸ”’ Security

  • Smart Contracts: Audited by OpenZeppelin
  • Data Privacy: IPFS + encryption
  • Access Control: Role-based permissions
  • Input Validation: Comprehensive sanitization

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ†˜ Support

Built with ❀️ by the ToxChain team

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •