It's your birthday? Prove it and get $100!
This project provides a simple contract and frontend for distributing USDC to people on their birthdays, serving as a straightforward example of integrating Self. This example introduces a contract that verifies a user's passport birthday and allows them to claim USDC if their date of birth is within ±5 days of the current date, along with a frontend that integrates this functionality.
- It is recommended to install ngrok before starting, which will be useful for testing the frontend locally.
-
Navigate to the contracts directory:
cd contracts
-
Install dependencies:
yarn install
-
Build the contracts:
yarn run build
-
Configure the passport environment in the
contracts/ignition/modules/SelfHappyBirthday.ts
file:- For real passports (production environment):
Uncomment the line for production and comment the staging line:
// For prod environment const DEFAULT_IDENTITY_VERIFICATION_HUB = "0x9AcA2112D34Ef021084264F6f5eef2a99a5bA7b1"; // For staging environment // const DEFAULT_IDENTITY_VERIFICATION_HUB = "0xDCAa9D9b8E8Bb5696c5d4b47da84aD37b8DEb9A8";
- For mock passports (staging/testing environment):
Keep the staging environment line uncommented (default):
// For prod environment // const DEFAULT_IDENTITY_VERIFICATION_HUB = "0x9AcA2112D34Ef021084264F6f5eef2a99a5bA7b1"; // For staging environment const DEFAULT_IDENTITY_VERIFICATION_HUB = "0xDCAa9D9b8E8Bb5696c5d4b47da84aD37b8DEb9A8";
- For real passports (production environment):
Uncomment the line for production and comment the staging line:
-
Configure environment variables:
- Copy
.env.example
to.env
- Fill in the required values in the
.env
file
- Copy
-
Deploy the contracts:
yarn run deploy
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
yarn install
-
Configure environment variables:
- Copy
.env.example
to.env
- Fill in the required values in the
.env
file
- Copy
-
Update the contract address:
- Open
frontend/pages/api/verify.ts
- Find the line with
const contractAddress = "0x448333D3b622bc32629583a01e544f7bc7509237";
- Replace the address with the address of your newly deployed contract
- Open
-
Configure the passport mode in
frontend/app/page.tsx
:- For real passports (production environment):
Set
devMode
tofalse
in theselfApp
configuration:devMode: false,
- For mock passports (staging/testing environment):
Set
devMode
totrue
in theselfApp
configuration:devMode: true,
- For real passports (production environment):
Set
-
Start the development server:
yarn dev
-
Set up ngrok for local development:
- In a new terminal, start ngrok to expose your local server:
ngrok http 3000
- Copy the generated ngrok URL (it will look like
https://xxxx-xxx-xxx-xx.ngrok-free.app
) - Open
frontend/app/page.tsx
and find theendpoint
line in theselfApp
configuration (around line 60) - Replace the existing URL with your ngrok URL:
endpoint: "https://your-ngrok-url.ngrok-free.app/api/verify",
- In a new terminal, start ngrok to expose your local server:
-
Open http://localhost:3000 in your browser to view the application.