Learn to build privacy-preserving identity verification with Self Protocol - from frontend QR codes to smart contract attestations on Celo.
πΊ New to Self? Watch the ETHGlobal Workshop first.
- Node.js 20+
- Self Mobile App (iOS/Android)
- Celo wallet with testnet funds
# Clone the workshop repository
git clone <repository-url>
cd workshop
# Install frontend dependencies
cd app
npm install
cd ..
# Install contract dependencies
cd contracts
npm install
forge install foundry-rs/forge-std
Navigate to the contracts folder and configure deployment:
# Copy and configure environment
cp .env.example .env
Edit .env
with your values:
# Your private key (with 0x prefix)
PRIVATE_KEY=0xyour_private_key_here
# Network selection
NETWORK=celo-sepolia
# Scope calculation
SCOPE_SEED="self-workshop"
Deploy the contract:
# Make script executable
chmod +x script/deploy-proof-of-human.sh
# Deploy contract (handles everything automatically)
./script/deploy-proof-of-human.sh
β οΈ Troubleshooting Celo Sepolia: If you encounter aChain 11142220 not supported
error when usingcelo-sepolia
, update Foundry to version 0.3.0:foundryup --install 0.3.0
The script will:
- β Build contracts with Foundry
- β Deploy ProofOfHuman contract
- β Verify contract on CeloScan
- β Display deployment summary
Configure the frontend:
cd ../app # Go to app directory
cp .env.example .env
Edit .env
:
# Your deployed contract address from Step 3
# notice that the address should be lowercase
NEXT_PUBLIC_SELF_ENDPOINT=0xyour_contract_address
# App configuration
NEXT_PUBLIC_SELF_APP_NAME="Self Workshop"
NEXT_PUBLIC_SELF_SCOPE="self-workshop"
# Navigate to app directory and start the Next.js development server
cd app
npm run dev
Visit http://localhost:3000
to see your verification application!
The Self SDK is configured in your React components:
import { SelfAppBuilder } from '@selfxyz/core';
const selfApp = new SelfAppBuilder({
// Contract integration settings
endpoint: process.env.NEXT_PUBLIC_CONTRACT_ADDRESS,
endpointType: "staging_celo", // Use "celo" for mainnet
userIdType: "hex", // For wallet addresses
version: 2, // Always use V2
// App details
appName: "Self Workshop",
scope: "self-workshop",
userId: userWalletAddress,
disclosures: {
// Verification requirements (must match your contract config)
minimumAge: 18,
excludedCountries: ["USA"], // 3-letter country codes
ofac: false, // OFAC compliance checking
// disclosures
name: true, // Request name disclosure
nationality: true, // Request nationality disclosure
gender: true, // Request gender disclosure
date_of_birth: true, // Request date of birth disclosure
passport_number: true, // Request passport number disclosure
expiry_date: true, // Request expiry date disclosure
}
}).build();
Your contract extends SelfVerificationRoot
:
contract ProofOfHuman is SelfVerificationRoot {
mapping(address => bool) public verifiedHumans;
bytes32 public verificationConfigId;
constructor(
address _hubAddress,
uint256 _scope,
bytes32 _verificationConfigId
) SelfVerificationRoot(_hubAddress, _scope) {
verificationConfigId = _verificationConfigId;
}
function customVerificationHook(
ISelfVerificationRoot.GenericDiscloseOutputV2 memory output,
bytes memory userData
) internal override {
// Mark user as verified
address userAddress = address(uint160(output.userIdentifier));
verifiedHumans[userAddress] = true;
emit VerificationCompleted(output, userData);
}
}
- Hub Address:
0x16ECBA51e18a4a7e61fdC417f0d47AFEeDfbed74
- RPC:
https://forno.celo-sepolia.celo-testnet.org
- Explorer:
https://celo-sepolia.blockscout.com/
- Supports: Mock passports for testing
- Hub Address:
0xe57F4773bd9c9d8b6Cd70431117d353298B9f5BF
- RPC:
https://forno.celo.org
- Explorer:
https://celoscan.io
- Supports: Real passport verification
- π± Telegram Community: Self Protocol Support
- π Documentation: docs.self.xyz
- π₯ Workshop Video: ETHGlobal Cannes
- π¬ GitHub Issues: Report workshop-specific issues
workshop/
βββ app/
β βββ app/
β β βββ verified/page.tsx # Success page
β β βββ page.tsx # Main QR code page
β β βββ layout.tsx # Root layout
β βββ components/ # React components
βββ contracts/
β βββ src/ProofOfHuman.sol # Main contract
β βββ script/
β β βββ Deploy*.s.sol # Deployment scripts
β β βββ deploy-proof-of-human.sh # Deployment automation
β βββ .env.example # Contract environment template
β βββ foundry.toml # Foundry configuration
β βββ DEPLOYMENT.md # Detailed deployment guide
βββ public/ # Static assets
βββ .env.example # Frontend environment template
βββ README.md # This file
- Self Protocol Docs - Complete protocol documentation
- Contract Integration Guide - Smart contract specifics
- Frontend SDK Reference - Frontend integration details
- Verification Disclosures - Available verification options
- tools.self.xyz - Configuration and deployment tools
- Self Mobile Apps - iOS and Android apps
- Celo Documentation - Blockchain platform docs
- Foundry Documentation - Smart contract framework
- Self Protocol Telegram - Community support
- GitHub Repository - Source code and issues
- ETHGlobal Workshop - Video tutorial