For the complete documentation index, see llms.txt. This page is also available as Markdown.

Happy Birthday Example

This example demonstrates the V2 Happy Birthday contract that distributes USDC to users on their birthday, with document type bonuses.

Birthday-Specific Features

  • Birthday Window Validation: Configurable time window around user's birthday

  • Document Type Bonuses (example scope): Different reward multipliers for E-Passport vs EU ID cards

  • Date Processing: Simplified handling of pre-extracted V2 date attributes

  • One-time Claims: Nullifier prevents multiple birthday claims

Self V2 supports additional attestation types (Aadhaar and KYC). This example contract demonstrates bonus logic only for E-Passport and EU ID card.

For standard V2 integration patterns, see Basic Integration Guide.

State Variables

/// @notice USDC token contract
IERC20 public immutable usdc;

/// @notice Default: 50 USDC (6 decimals)
uint256 public claimableAmount = 50e6;

/// @notice Bonus multiplier for EU ID card users (in basis points)
uint256 public euidBonusMultiplier = 200; // 200% = 2x bonus

/// @notice Bonus multiplier for E-Passport users (in basis points) 
uint256 public passportBonusMultiplier = 150; // 150% = 1.5x bonus

/// @notice Birthday claim window (default: 1 day)
uint256 public claimableWindow = 1 days;

/// @notice Tracks users who have claimed to prevent double claims
mapping(uint256 nullifier => bool hasClaimed) public hasClaimed;

/// @notice Verification config ID for identity verification
bytes32 public verificationConfigId;

uint256 public constant BASIS_POINTS = 10000;

Birthday Verification Logic

The core birthday validation uses V2's pre-extracted date format:

Birthday Verification Hook:

V2 Simplified Birthday Verification

The V2 implementation dramatically simplifies birthday verification by using pre-extracted date attributes:

Document Type Bonuses

The V2 implementation provides different bonuses based on document type:

Administrative Functions

Birthday Contract Benefits

V2 Date Simplification: Direct access to output.dateOfBirth eliminates complex parsing Multi-Document Rewards: Different bonus structures for passport vs EU ID card users Flexible Windows: Configurable birthday claim periods Admin Controls: Owner can adjust amounts, windows, and bonuses

For verification configuration setup, see Hub Verification Process.

Configuration Management

The contract includes methods for managing verification configuration:

Example Usage

  1. Deploy Contract: With hub address, scope, and USDC token address

  2. Set Configuration: Call setConfigId() with your verification config ID or use setupVerificationConfig() pattern

  3. Fund Contract: Transfer USDC to contract for distribution

  4. User Claims: Users verify identity and automatically receive birthday bonus

  5. Document Bonuses: EU ID card users get 2x, passport users get 1.5x the base amount

Last updated