This project demonstrates the usage of the PHI SDK for creating and verifying credentials (Creds) and artworks (Arts) using the PHI protocol.
- Create Merkle-based Creds
- Create Signature-based Creds
- Create Image-based Arts
- Create API-based Arts
- Set up verifiers for Creds
Deploy the example using Vercel:
This repository provides examples for creating verifier endpoints, Creds, and Artworks using the PHI SDK. Follow these steps to use the project:
- Install Dependencies
- bun install
-
Set up environment variables:
- Copy
.env.sampleto.envand fill in the required values. - Ensure
BASESCAN_API_KEYis set for Etherscan API calls.
- Copy
-
Create Verifier Endpoint:
- Implement verifier logic in
api/verify/[id].tsfor each Cred type. - Use the
credVerifyEndpointobject insrc/cred/credConfig.tsto map Cred IDs to their respective verifier endpoints.
- Implement verifier logic in
-
Create Cred:
- Use the
credConfigobject insrc/cred/credConfig.tsto define Cred configurations. - (Implement Cred creation logic in
src/cred/createCredRequest.ts.)
- Use the
-
Create Artwork:
- Use the
artSettingsobject insrc/art/artConfig.tsto define Art configurations. - (Implement Art creation logic in
src/art/createArtRequest.ts.) - For API-based Arts, refer to
api/generate.tsorapi/gif.tsfor endpoint implementation examples.
- Use the
-
Run script
- bun run src/main.ts
export const credConfig: { [key: number]: CredConfig } = {
0: {
title: 'Number of transactions on Basechain',
requirement: 'Execute any transaction on Basechain',
credType: 'ADVANCED',
verificationType: 'SIGNATURE',
// ... other properties
},
// ... other Cred configurations
};
export const credVerifyEndpoint: { [key: number]: string | undefined } = {
0: 'https://phi-sdk.vercel.app/api/verify/0',
// ... other verifier endpoints
};export const artSettings: { [key: number]: ArtSetting } = {
0: {
name: 'Base Transaction Art',
description: 'Art representing transactions on Basechain',
artType: 'IMAGE',
// ... other properties
},
// ... other Art configurations
};bun run test
- src/cred/: Contains functions for creating Creds
- src/art/: Contains functions for creating Arts
- src/verifier/: Contains functions for setting up verifiers
- src/utils/: Contains utility functions and configuration
- api/: Contains API endpoints for verifying Creds and generating images
- public/assets/: Contains sample images and fonts
- csv/: Contains sample CSV files for Merkle-based Creds
This project is licensed under the MIT License - see the LICENSE.md file for details.