The GitStreamReceiver smart contract requires a bytes32 project ID for all payment operations. This ID is computed using keccak256(abi.encodePacked(repoUrl, ownerAddress)) to uniquely identify each project.
- File:
apps/api/src/lib/contract-utils.ts - Function:
computeProjectId(repoUrl: string, ownerAddress: string): string - Computes the project ID using the same algorithm as the smart contract
- Uses ethers.js
solidityPackedandkeccak256functions
- File:
apps/api/src/routes/projects.ts - Automatically computes and stores
projectIdBytes32when creating new projects - Includes
projectIdBytes32in all API responses (GET, PUT endpoints)
- File:
apps/api/src/db/models/project.ts - Already had the
projectIdBytes32?: stringfield defined - Now properly populated for all new projects
- File:
apps/web/app/project/[id]/page.tsx - Displays the project ID below the repository name
- Shows truncated version:
0x1234...abcd5678 - Includes a copy-to-clipboard button with visual feedback
- Only shown when
projectIdBytes32is available
- File:
apps/web/lib/api.ts - Already had the
projectIdBytes32?: stringfield in the Project type
Existing projects in the database don't have the projectIdBytes32 field populated.
Run this script to update all existing projects:
pnpm --filter=api tsx src/scripts/migrate-project-ids.tsThe script will:
- Find all projects without a
projectIdBytes32 - Compute the correct value based on
repoUrlandownerAddress - Update each project in the database
- Print progress and summary
When your app needs to send USDC to the GitStreamer contract, use the projectIdBytes32:
// Example: Sending revenue to a project
const projectId = project.projectIdBytes32; // e.g., "0x1234...abcd"
// Call the contract's receiveRevenue function
await gitStreamReceiver.receiveRevenue(projectId, amount);The project detail page now shows the project ID prominently with a copy button, making it easy for users to:
- Copy the ID for payment integrations
- Verify it matches what's expected in the contract
- Share it with third-party payment services
# Start the API
pnpm --filter=api dev
# Create a new project via the API
# The response should include projectIdBytes32# Run the migration script
pnpm --filter=api tsx src/scripts/migrate-project-ids.ts
# Verify existing projects have the field# Start the web app
pnpm --filter=web dev
# Navigate to a project detail page
# Verify the project ID is displayed with copy functionalityThe projectIdBytes32 computed by the backend must match what the smart contract computes. Verify this by:
// In the contract
function getProjectId(string calldata repoUrl, address owner) public pure returns (bytes32) {
return keccak256(abi.encodePacked(repoUrl, owner));
}// In the backend (computeProjectId function)
const encoded = ethers.solidityPacked(["string", "address"], [repoUrl, ownerAddress]);
return ethers.keccak256(encoded);Both should produce identical results.
- Run the migration script to update existing projects
- Test the payment flow end-to-end with the project ID
- Update any documentation that references project identification
- Consider adding the project ID to other relevant pages (dashboard, project list, etc.)