TruthChain is a decentralized content verification system that creates a tamper-proof proof-of-truth layer for digital content. Fight misinformation with blockchain technology.
- β Verified Creator Identity - On-chain registration for journalists and media outlets
- π Content Hashing & Timestamping - SHA-256 hashing with blockchain storage
- π¦ IPFS Decentralized Storage - Metadata stored on IPFS via Pinata
- π Instant Content Verification - Verify authenticity in seconds
- π Transparent Version History - Track all content updates immutably
- β Creator Reputation System - Trust scores for content creators
- π¨ Professional UI - Modern, responsive design with glassmorphism
- π Polygon blockchain integration (low cost, fast transactions)
- π¦ MetaMask wallet connection
- π± Fully responsive design
- π Beautiful animations and transitions
- βΏ SEO optimized
βββββββββββββββββββ
β Frontend β
β (Next.js) β
ββββββββββ¬βββββββββ
β
βββββββββββββββββββ
β β
ββββββββββΌβββββββββ βββββββΌβββββββββββ
β Smart Contractsβ β IPFS (Pinata) β
β (Polygon) β β (Metadata) β
βββββββββββββββββββ ββββββββββββββββββ
Before you begin, ensure you have:
- Node.js (v18 or higher)
- npm or yarn
- MetaMask browser extension
- Polygon testnet MATIC (for deployment)
- Pinata account (for IPFS storage)
git clone <your-repo-url>
cd TruthChain# Install root dependencies (Hardhat)
npm install
# Install frontend dependencies
cd frontend
npm install
cd ..cp .env.example .envEdit .env:
# Get from https://www.alchemy.com/ or https://infura.io/
POLYGON_AMOY_RPC_URL=https://rpc-amoy.polygon.technology
# Your MetaMask private key (NEVER commit this!)
PRIVATE_KEY=your_private_key_here
# Get from https://polygonscan.com/apis
POLYGONSCAN_API_KEY=your_api_key_herecd frontend
cp env.example .env.localEdit frontend/.env.local:
# Will be auto-populated after deployment
NEXT_PUBLIC_CREATOR_REGISTRY_ADDRESS=
NEXT_PUBLIC_TRUTHCHAIN_ADDRESS=
# Network Configuration
NEXT_PUBLIC_NETWORK_NAME=polygonAmoy
NEXT_PUBLIC_CHAIN_ID=80002
NEXT_PUBLIC_RPC_URL=https://rpc-amoy.polygon.technology
# Get from https://app.pinata.cloud/
NEXT_PUBLIC_PINATA_API_KEY=your_pinata_api_key
NEXT_PUBLIC_PINATA_SECRET_KEY=your_pinata_secret_key
NEXT_PUBLIC_PINATA_JWT=your_pinata_jwt- Visit Polygon Faucet
- Select "Polygon Amoy Testnet"
- Enter your wallet address
- Receive free testnet MATIC
npx hardhat compilenpx hardhat run scripts/deploy.js --network polygonAmoyThis will:
- Deploy CreatorRegistry contract
- Deploy TruthChain contract
- Save deployment addresses to
deployments/polygonAmoy.json - Copy ABIs to
frontend/lib/contracts/
After deployment, update frontend/.env.local with the contract addresses from deployments/polygonAmoy.json:
NEXT_PUBLIC_CREATOR_REGISTRY_ADDRESS=0x...
NEXT_PUBLIC_TRUTHCHAIN_ADDRESS=0x...cd frontend
npm run devVisit http://localhost:3000
-
Connect Wallet
- Click "Connect Wallet" in the navigation
- Approve MetaMask connection
-
Register as Creator
- Go to "Creator Portal"
- Fill in your name and organization
- Click "Register on Blockchain"
- Approve the transaction in MetaMask
- Wait for admin verification
-
Upload Content
- Once verified, go to "Upload Content" tab
- Enter content details
- Click "Publish to Blockchain"
- Approve the transaction
-
Verify Content
- Go to "Verify Content"
- Choose verification method:
- Text: Paste content directly
- File: Upload a file
- URL: Enter a URL
- Click "Verify Content"
- View results:
- β Authentic: Content is verified
- β Not Found: Content not registered
β οΈ Edited: Content has been modified
-
Explore Content
- Go to "Explore"
- Browse all verified content
- Use search and filters
- View creator information
TruthChain/
βββ contracts/ # Smart contracts
β βββ CreatorRegistry.sol
β βββ TruthChain.sol
βββ scripts/ # Deployment scripts
β βββ deploy.js
βββ test/ # Contract tests
βββ frontend/ # Next.js application
β βββ app/ # Pages
β β βββ page.tsx # Home
β β βββ verify/ # Verification
β β βββ creator/ # Creator portal
β β βββ explore/ # Browse content
β βββ components/ # React components
β βββ contexts/ # React contexts
β βββ lib/ # Utilities
β βββ web3.ts # Web3 helpers
β βββ hash.ts # Hashing utilities
β βββ ipfs.ts # IPFS integration
βββ hardhat.config.js # Hardhat configuration
# Compile contracts
npx hardhat compile
# Run tests
npx hardhat test
# Deploy to local network
npx hardhat run scripts/deploy.js --network hardhat
# Deploy to Polygon Amoy testnet
npx hardhat run scripts/deploy.js --network polygonAmoy
# Verify contract on Polygonscan
npx hardhat verify --network polygonAmoy <CONTRACT_ADDRESS>
# Run frontend
cd frontend && npm run dev
# Build frontend for production
cd frontend && npm run build# Run all tests
npx hardhat test
# Run with gas reporting
REPORT_GAS=true npx hardhat test
# Run specific test file
npx hardhat test test/TruthChain.test.js- Update hardhat.config.js with Polygon mainnet RPC
- Get mainnet MATIC for gas fees
- Update .env with mainnet configuration
- Deploy contracts:
npx hardhat run scripts/deploy.js --network polygon
- Verify contracts:
npx hardhat verify --network polygon <CONTRACT_ADDRESS>
- Push to GitHub
- Import to Vercel
- Add environment variables in Vercel dashboard
- Deploy
TruthChain includes a comprehensive testing suite with 71+ test cases covering all functionality.
# 1. Start the development server
cd frontend
npm run dev
# 2. Open browser to http://localhost:3000
# 3. Open DevTools Console (F12)
# 4. Clear localStorage
localStorage.clear()We provide 4 comprehensive testing documents:
- TESTING_INDEX.md - Start here! Overview of all testing resources
- COMPREHENSIVE_TEST_SUITE.md - 71 detailed test cases across 10 categories
- QUICK_TEST_GUIDE.md - 10-minute smoke test with automated console tests
- VISUAL_TEST_CHECKLIST.md - Step-by-step manual testing checklist
Follow the Complete Creator Journey (5 minutes):
- Register β Connect wallet, register as creator
- Admin Approve β Go to /admin, approve creator, get security key
- Upload β Login, unlock upload, publish content
- Verify β Copy hash, verify on /verify page
- Explore β Check content appears on /explore page
β PASS if all steps work and data appears correctly across all pages.
Run in browser console for instant verification:
// Quick health check
const content = JSON.parse(localStorage.getItem('truthchain_content') || '[]');
const creators = JSON.parse(localStorage.getItem('admin_creators') || '[]');
console.log(`β Content Items: ${content.length}`);
console.log(`β Registered Creators: ${creators.length}`);
console.log(`β Approved Creators: ${creators.filter(c => c.status === 'approved').length}`);| Feature Area | Test Cases | Coverage |
|---|---|---|
| Authentication | 10 | 100% |
| Content Upload | 10 | 100% |
| Verification Portal | 12 | 100% |
| Admin Controls | 8 | 100% |
| Content Discovery | 8 | 100% |
| Data Persistence | 5 | 100% |
| Integration | 5 | 100% |
| Total | 71+ | 100% |
β
Creator registration and authentication
β
Admin approval workflow with security keys
β
Content upload with verification animation
β
Hash-based content verification
β
Tamper detection (edited content)
β
Version history tracking
β
Content exploration and search
β
Admin content moderation
β
Data persistence across page refreshes
β
Cross-page data interlinking
For detailed testing instructions, see TESTING_INDEX.md.
β οΈ Never commit private keys to version controlβ οΈ Use environment variables for sensitive dataβ οΈ Audit smart contracts before mainnet deploymentβ οΈ Test thoroughly on testnet firstβ οΈ Implement access controls for admin functions
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License.
- Polygon - Scalable blockchain infrastructure
- IPFS/Pinata - Decentralized storage
- Next.js - React framework
- Hardhat - Ethereum development environment
- ethers.js - Ethereum library
For questions or issues:
- Open an issue on GitHub
- Contact the development team
Built with β€οΈ to fight misinformation
TruthChain - Because truth matters