A simple, no-blockchain template for demonstrating Self protocol passport verification. Perfect for hackathons, workshops, and getting started with Self!
- Verify humanity using passport verification (no blockchain required!)
- Zero complexity - just frontend + backend API
- 5-minute setup - clone, install, scan QR code
- Perfect for demos - works with mock passports
Absolutely โ that's a clearer and more streamlined flow. Here's an updated version of steps 1โ6, rewritten to reflect your preferred structure and emphasize the directory context, ngrok setup, and the /api/verify path.
Set up and run the demo in development mode using mock passports. This process involves launching the backend server, exposing it via ngrok, and configuring the frontend accordingly.
From the project root, navigate to the backend directory and install dependencies:
cd backend
yarn installThen, start the backend server:
yarn devThe backend will run locally at http://localhost:3001.
Now, expose the backend to the public internet using ngrok:
ngrok http 3001Copy the HTTPS URL from the terminal output (e.g., https://abc123.ngrok.app).
Important: This URL will be used in the frontend configuration and must include the
/api/verifypath when specified.
Open a new terminal, navigate to the frontend directory, and install dependencies:
cd frontend
yarn installIn frontend/app/page.tsx, update the endpoint value to include your ngrok URL with the /api/verify path:
endpoint: "https://abc123.ngrok.app/api/verify"Now, start the frontend application:
yarn devThe frontend will be available at http://localhost:3000.
- Open
http://localhost:3000in your browser - Use the Self mobile app to scan the displayed QR code
- Complete the passport verification flow (mock or real) - mock is set per default, so see below how to change it to real passport
- You should see a confirmation message indicating successful verification
Let me know if you'd like this integrated into the full README or converted to Docusaurus/GitBook syntax.
- Download Self app from app store
- Create mock passport in app
- Use any details (name, nationality, etc.)
- Scan QR code to verify
- Scan your real passport with Self app
- Update backend to use production mode
- In
backend/index.tsChangeyou need to set the use of the mockPassport to false in theselfBackendVerifier
const selfBackendVerifier = new SelfBackendVerifier(
'prove-human-demo', // Same scope as frontend
verifyEndpoint, // The endpoint Self backend will call
'uuid', // User ID type
true // set to false to test with your real passport
);
- QR Code Display: Uses
@selfxyz/qrcodepackage - User Interface: Beautiful verification flow with success/error states
- No Blockchain: Pure web app, no wallet connections needed
- Proof Verification: Uses
@selfxyz/coreSelfBackendVerifier - API Endpoint: Self backend calls
/api/verifyto validate proofs - No Smart Contracts: Verification happens off-chain
- Frontend: Generates QR codes with verification requests
- Self App: User scans passport and QR code
- Backend: Receives and verifies cryptographic proofs
- Result: Confirmed human verification
const selfApp = new SelfAppBuilder({
appName: "Prove You're Human",
scope: "prove-human-demo", // Unique app identifier
endpoint: "https://your-ngrok.ngrok.app/api/verify",
endpointType: "https", // Backend API mode
userId: uuidv4(), // Unique user ID
userIdType: "uuid", // ID type
disclosures: { // What data to request
issuing_state: true,
name: true,
nationality: true,
},
devMode: true, // Development mode
}).build();const selfBackendVerifier = new SelfBackendVerifier(
'prove-human-demo', // Same scope as frontend
verifyEndpoint, // This backend's verify endpoint
'uuid', // User ID type
true // true = mock passports, false = real passports
);- Deploy frontend to your hosting platform
- Set environment variables for production API URL
- Update CORS settings in backend
- Deploy backend to your hosting platform
- Set
NODE_ENV=production - Update frontend with production backend URL
- Configure CORS for your frontend domain
Change backend configuration:
const selfBackendVerifier = new SelfBackendVerifier(
'your-production-scope',
'https://your-backend.com/api/verify',
'uuid',
false // Use real passports
);Verifies Self protocol proofs and returns verification result.
Request Body:
{
"proof": { ... }, // Cryptographic proof from Self app
"publicSignals": [ ... ] // Public verification data
}Success Response (200):
{
"status": "success",
"result": true,
"message": "Human verification successful",
"data": {
"userId": "uuid-here",
"verifiedAt": "2025-06-13T...",
"nationality": "USA",
"name": "John Doe",
"issuingState": "US"
}
}Error Response (400/500):
{
"status": "error",
"result": false,
"message": "Human verification failed",
"details": { ... }
}prove-human/
โโโ frontend/ # Next.js app
โ โโโ app/ # Pages and components
โ โโโ package.json # Frontend dependencies
โ โโโ ...
โโโ backend/ # Express.js API
โ โโโ src/ # TypeScript source
โ โโโ package.json # Backend dependencies
โ โโโ ...
โโโ README.md # This file
- Frontend:
@selfxyz/qrcode,next,react,uuid - Backend:
@selfxyz/core,express,cors,helmet
# Frontend
yarn dev # Start development server
yarn build # Build for production
yarn lint # Run ESLint
# Backend
yarn dev # Start with hot reload
yarn build # Compile TypeScript
yarn start # Run production buildThis template is perfect for:
- Hackathon kickstarts - Get Self integration running in 5 minutes
- Anti-bot systems - Verify real humans for your platform
- Identity workshops - Teach zero-knowledge proofs and privacy
- Community gating - Humans-only Discord/Telegram bots
- Age verification - Prove 18+ without revealing exact age
- Nationality checks - Country-based access control
- Development Only: This template uses mock passports and development settings
- Production: Switch to real passport mode and proper environment configuration
- Private Data: Self protocol ensures passport data stays private and secure
- No Blockchain: No gas fees, private keys, or wallet management required
1. "Endpoint not accessible" error
- โ Make sure ngrok is running on the backend port (3001)
- โ Update frontend with correct ngrok HTTPS URL
- โ Backend should be accessible via ngrok URL
2. "CORS error" in browser
- โ Check CORS configuration in backend
- โ Make sure frontend origin is allowed
- โ Verify FRONTEND_URL environment variable
3. "Verification failed" message
- โ Check backend logs for detailed error messages
- โ Ensure scope matches between frontend and backend
- โ Verify mock passport mode is enabled for testing
4. "QR code not working"
- โ Make sure Self mobile app is installed
- โ Check that ngrok URL is HTTPS (not HTTP)
- โ Verify QR code is displaying correctly
Enable detailed logging:
# Backend terminal
DEBUG=* yarn dev
# Check browser console for frontend errors
# Check terminal for backend logs- Add Database: Store verification results
- Add Authentication: User accounts and sessions
- Add Features: Age verification, nationality filtering
- Add UI: Better design, animations, branding
- Add Analytics: Track verification success rates
Ready for on-chain verification? Check out:
- Self Contracts Documentation
- Birthday Example - Full smart contract integration
- Airdrop Example
Found a bug or want to improve this template?
- Fork the repository
- Create your feature branch
- Submit a pull request
MIT License - feel free to use this template for your projects!
Built with โค๏ธ using Self Protocol