EduChain AI is a decentralized educational platform that combines Artificial Intelligence with Blockchain Technology to evaluate students and issue tamper-proof NFT certificates.
- AI Layer — KNN Classifier analyzes student performance (score, attempts, time)
- Blockchain Layer — Smart Contract validates and mints ERC-721 Soulbound NFTs
- Storage Layer — NFT metadata stored permanently on IPFS via Pinata
Student → Frontend (React) → AI Backend (FastAPI) ↓ Validator signs transaction ↓ Smart Contract (Sepolia) ↓ NFT Minted to Student Wallet
| Layer | Technology |
|---|---|
| Smart Contract | Solidity 0.8.26, OpenZeppelin, Hardhat |
| Blockchain | Ethereum Sepolia Testnet |
| Frontend | React.js, Ethers.js, Tailwind CSS |
| AI Backend | Python, FastAPI, Scikit-learn (KNN) |
| Storage | IPFS, Pinata |
| Wallet | MetaMask |
EduChain/ ├── contracts/ │ └── EduChain.sol # Smart Contract ├── scripts/ │ └── deploy.js # Deployment Script ├── test/ │ └── EduChain.test.js # Unit Tests ├── frontend/ │ └── src/ │ ├── App.jsx │ └── components/ │ ├── Navbar.jsx │ ├── Quiz.jsx │ ├── Result.jsx │ └── Verify.jsx ├── backend/ │ └── main.py # AI Backend ├── hardhat.config.js ├── .env └── README.md
- Node.js v20+
- Python 3.10+
- MetaMask Browser Extension
# Install Hardhat dependencies
npm install
# Install Frontend dependenciescd frontend
npm install
cd ..
# Install Backend dependenciescd backend
python -m venv venv
venv\Scripts\activate
pip install fastapi uvicorn scikit-learn numpy web3 python-dotenv httpx
cd ..Create .env in root folder:
PRIVATE_KEY=your_wallet_private_key SEPOLIA_RPC_URL=your_alchemy_sepolia_url ETHERSCAN_API_KEY=your_etherscan_api_key
Create .env in backend/ folder:
PRIVATE_KEY=your_validator_private_key SEPOLIA_RPC_URL=your_alchemy_sepolia_url CONTRACT_ADDRESS=your_deployed_contract_address PINATA_JWT=your_pinata_jwt_token
npx hardhat compilenpx hardhat testExpected output:
EduChain Happy Path ✔ Should mint NFT certificate for passing student Failed Validation ✔ Should revert if score is below minimum ✔ Should revert if attempts exceed maximum Unauthorized Access ✔ Should revert if caller is not the validator 4 passing
npx hardhat run scripts/deploy.js --network sepoliaCopy the contract address and update it in:
backend/.env→CONTRACT_ADDRESSfrontend/src/App.jsx→CONTRACT_ADDRESSfrontend/src/components/Result.jsx→CONTRACT_ADDRESSfrontend/src/components/Verify.jsx→CONTRACT_ADDRESS
Terminal 1 — AI Backend:
cd backend
venv\Scripts\activate
uvicorn main:app --reloadTerminal 2 — Frontend:
cd frontend
npm run devOpen browser at: http://localhost:5173
- Student connects MetaMask wallet
- Student takes quiz (10 random questions from 50)
- Each question has a 30-second timer
- AI Backend analyzes: score (60%) + attempts (25%) + time (15%)
- KNN Classifier determines performance level
- If passed → Student mints NFT Certificate
- Validator Backend signs and submits to Smart Contract
- Contract verifies and mints Soulbound ERC-721 NFT
- If failed → Attempt recorded on blockchain automatically
- After 3 failed attempts → Wallet permanently banned
| Feature | Implementation |
|---|---|
| Access Control | onlyValidator modifier |
| Reentrancy Protection | ReentrancyGuard + CEI pattern |
| Double Certification | notCertified modifier |
| Soulbound NFT | Disabled transfer functions |
| Ban System | On-chain failed attempts tracking |
| Input Validation | require() with descriptive messages |
| Property | Value |
|---|---|
| Network | Ethereum Sepolia Testnet |
| Contract Address | 0x7297C08190DC726ce1fbDC62F14336Ae090a3aA6 |
| Token Standard | ERC-721 Soulbound |
| Minimum Score | 60% |
| Maximum Attempts | 3 |
| Validator | Deployer Address |
| Test | Description | Status |
|---|---|---|
| Happy Path | Valid student passes and receives NFT | ✅ |
| Score Below Minimum | Transaction reverts if score < 60 | ✅ |
| Max Attempts Exceeded | Transaction reverts if attempts > 3 | ✅ |
| Unauthorized Access | Non-validator call reverts | ✅ |
Model: K-Nearest Neighbors (KNN) Features: [score, attempts, completion_time] Training Samples: 60 samples (12 per class) Classes: Excellent / Good / Pass / Weak Pass / Fail Normalization: MinMaxScaler
MIT License
Manal Mahmoud Shahd Ibrahim