Skip to content

princessoladele/VacciChain

Β 
Β 

Repository files navigation

Vacci-Chain

CI

Blockchain-based vaccination records on Stellar β€” soulbound, verifiable, tamper-proof.

VacciChain lets governments and healthcare providers issue vaccination records as non-transferable NFTs (soulbound tokens) on the Stellar network via Soroban smart contracts. Patients hold records in their Stellar wallets. Schools, employers, and border agencies verify status on-chain β€” no central database, no forgery.


Features

  • Issuer-gated minting β€” only authorized healthcare providers can issue vaccination NFTs
  • Soulbound tokens β€” all transfer attempts are reverted at the contract level
  • On-chain verification β€” any third party can verify a wallet's vaccination status publicly
  • SEP-10 authentication β€” Stellar Web Auth for secure, replay-protected sessions
  • Analytics service β€” vaccination rates, issuer activity, and anomaly detection
  • Fully dockerized β€” one command to spin up the entire stack

🌐 Public Demo Environment

You can explore VacciChain without setting up a local environment by visiting our live testnet demo.

  • Network: Stellar Testnet
  • Reset Schedule: Weekly (Every Sunday at 00:00 UTC)

Testing as an Issuer

To evaluate the issuer flow (minting and revoking records), you can connect your Freighter wallet using testnet credentials. Ensure your wallet is set to Testnet.

⚠️ Security Warning: The demo database and contract state are wiped periodically.

πŸš€ Staging Environment

A production-equivalent staging environment is automatically deployed on every merge to main:

See docs/staging-environment.md for testing and monitoring procedures.


Architecture

vacci-chain/
β”œβ”€β”€ contracts/                   # Rust β€” Soroban smart contracts
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ lib.rs               # Contract entrypoint
β”‚   β”‚   β”œβ”€β”€ mint.rs              # Issue vaccination NFT
β”‚   β”‚   β”œβ”€β”€ verify.rs            # On-chain verification logic
β”‚   β”‚   β”œβ”€β”€ storage.rs           # Key-value storage schemas
β”‚   β”‚   └── events.rs            # Contract event definitions
β”‚   β”œβ”€β”€ Cargo.toml
β”‚   └── Makefile                 # build, test, deploy targets
β”‚
β”œβ”€β”€ backend/                     # Node.js β€” Express REST API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js          # SEP-10 challenge + verify
β”‚   β”‚   β”‚   β”œβ”€β”€ vaccination.js   # Issue and fetch records
β”‚   β”‚   β”‚   └── verify.js        # Public verification endpoint
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js          # JWT guard middleware
β”‚   β”‚   β”‚   └── issuer.js        # Authorized issuer check
β”‚   β”‚   β”œβ”€β”€ stellar/
β”‚   β”‚   β”‚   β”œβ”€β”€ sep10.js         # Challenge generation + signature verify
β”‚   β”‚   β”‚   └── soroban.js       # Contract invocation helpers
β”‚   β”‚   └── app.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ frontend/                    # React β€” patient & issuer UI
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PatientDashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ IssuerDashboard.jsx
β”‚   β”‚   β”‚   └── VerifyPage.jsx
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useFreighter.js  # Wallet connect + SEP-10 flow
β”‚   β”‚   β”‚   └── useVaccination.js
β”‚   β”‚   └── components/
β”‚   β”‚       β”œβ”€β”€ NFTCard.jsx
β”‚   β”‚       └── VerificationBadge.jsx
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ python-service/              # Python β€” FastAPI analytics
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ analytics.py         # Vaccination rates, issuer stats
β”‚   β”‚   └── batch.py             # Bulk verification scripts
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”‚
└── docker-compose.yml

Tech Stack

Layer Technology
Smart Contracts Rust Β· Soroban SDK
Backend Node.js Β· Express.js Β· Stellar SDK
Frontend React Β· Freighter API
Analytics Python Β· FastAPI
Auth SEP-10 Β· JWT
Infrastructure Docker Β· Docker Compose
Network Stellar Testnet β†’ Mainnet

Smart Contract

The Soroban contract (contracts/) enforces all core rules. No backend can override it.

Functions

Function Access Description
mint_vaccination(patient, vaccine, date, issuer) Issuer only Issues a soulbound vaccination NFT
transfer(...) Blocked Always reverts β€” tokens are non-transferable
verify_vaccination(wallet) Public Returns vaccination status + metadata list
add_issuer(address) Admin only Authorizes a new healthcare provider
revoke_issuer(address) Admin only Removes issuer authorization

Storage Schema

patient_address  β†’  Vec<token_id>
token_id         β†’  VaccinationRecord { vaccine_name, date, issuer, timestamp }
issuer_address   β†’  bool (authorized)

Security Controls

  • Issuer allowlist checked on every mint
  • Duplicate record detection before minting
  • All inputs validated at contract boundary
  • Replay protection via SEP-10 nonces
  • No reentrancy patterns β€” single-entry invocation model
  • Safe arithmetic throughout
  • All critical actions emit on-chain events

Backend API

Base URL: http://localhost:4000

Auth

Method Endpoint Description
POST /auth/sep10 Generate SEP-10 challenge transaction
POST /auth/verify Verify signed challenge, issue JWT

Vaccination

Method Endpoint Auth Description
POST /vaccination/issue Issuer JWT Mint NFT via Soroban contract
GET /vaccination/:wallet JWT Fetch all records for a wallet

Verification

Method Endpoint Auth Description
GET /verify/:wallet None Public vaccination status check

Frontend Pages

Landing β€” Project overview and connect wallet CTA

Patient Dashboard β€” View all vaccination NFTs held in connected wallet, with vaccine name, date, and issuer details

Issuer Dashboard β€” Authorized issuers can fill and submit the vaccination form; mints directly to patient wallet via contract

Verification Page β€” Enter any Stellar wallet address and get an instant on-chain verification result with badge


🐍 Analytics Service

Base URL: http://localhost:8001

Endpoint Description
GET /analytics/rates Vaccination rates by vaccine type and region
GET /analytics/issuers Issuer activity β€” volume, frequency, last active
POST /batch/verify Bulk verify a list of wallet addresses
GET /analytics/anomalies Flag unusual minting patterns

SEP-10 Auth Flow

Client (Freighter)                Backend                    Stellar Network
      β”‚                              β”‚                              β”‚
      │── POST /auth/sep10 ─────────►│                              β”‚
      β”‚                              │── build challenge tx ───────►│
      │◄── challenge tx ─────────────│                              β”‚
      β”‚                              β”‚                              β”‚
      │── sign with wallet ───────────                              β”‚
      β”‚                              β”‚                              β”‚
      │── POST /auth/verify ────────►│                              β”‚
      β”‚     { signed_tx }            │── verify signature ─────────►│
      β”‚                              │◄── valid ────────────────────│
      │◄── JWT ──────────────────────│                              β”‚

Docker Setup

# Start all services
docker compose up --build

# Services and ports
# frontend        β†’ http://localhost:3000
# backend         β†’ http://localhost:4000
# python-service  β†’ http://localhost:8001

docker-compose.yml wires all services on an internal vaccichain network. Only frontend, backend, and analytics ports are exposed to the host.


Quick Start

Prerequisites

1. Clone & configure

git clone https://github.com/your-org/vacci-chain.git
cd vacci-chain
cp .env.example .env
# Fill in your Stellar keys and contract IDs

2. Deploy the contract

cd contracts
make build       # compile to WASM
make deploy      # deploy to testnet, outputs CONTRACT_ID
make test        # run contract unit tests

3. Run with Docker

docker compose up --build

4. Run locally (without Docker)

# Backend
cd backend && npm install && npm run dev

# Frontend
cd frontend && npm install && npm run dev

# Python service
cd python-service && pip install -r requirements.txt && uvicorn main:app --port 8001

Environment Variables

Copy .env.example to .env and fill in the required values. The backend validates all variables at startup and exits with a clear error message if anything is missing or malformed.

Variable Required Default Description
STELLAR_NETWORK no testnet testnet or mainnet
HORIZON_URL yes β€” Horizon REST API URL for the chosen network
SOROBAN_RPC_URL yes β€” Soroban RPC endpoint for contract calls
STELLAR_NETWORK_PASSPHRASE yes β€” Must exactly match the target network
VACCINATIONS_CONTRACT_ID yes β€” Deployed contract address (starts with C)
ADMIN_SECRET_KEY yes β€” Signs admin contract invocations (starts with S)
ADMIN_PUBLIC_KEY yes β€” Grants issuer role on SEP-10 login (starts with G)
SEP10_SERVER_KEY yes β€” Signs SEP-10 challenge transactions (starts with S)
ISSUER_SECRET_KEY yes β€” Signs mint/revoke transactions (starts with S)
JWT_SECRET yes β€” Signs JWTs; rotate to invalidate all sessions
PORT no 4000 Backend listen port
RATE_LIMIT_SEP10 no 10 Max SEP-10 requests per IP per minute
RATE_LIMIT_VERIFY no 60 Max verify requests per IP per minute
AUDIT_LOG_PATH no ./audit.log Path to append-only NDJSON audit log
ANALYTICS_PORT no 8001 Python analytics service port
BACKEND_URL no http://backend:4000 Analytics service β†’ backend base URL

For full descriptions, format rules, and examples see docs/configuration.md.


Testing

# Smart contract tests
cd contracts && cargo test

# Backend tests
cd backend && npm test

# Python service tests
cd python-service && pytest

Security Notes

  • Soulbound enforcement is at the contract level β€” no UI or backend can bypass it
  • Issuer authorization is on-chain β€” adding/removing issuers requires an admin-signed contract call
  • SEP-10 challenges expire after 5 minutes and are single-use
  • JWTs are short-lived (1 hour) and scoped by role (patient | issuer)
  • All contract events are emitted and indexable for audit trails

License

MIT Β© VacciChain Contributors

About

VacciChain is a blockchain-based vaccination record system on Stellar, issuing non-transferable NFT certificates with on-chain verification using Soroban and SEP-10 authentication.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 71.1%
  • Rust 19.4%
  • Python 6.7%
  • Shell 1.8%
  • Dockerfile 0.5%
  • Makefile 0.3%
  • Other 0.2%