Edit environments.toml and add your contract addresses:
[staging.contracts]
bulk_payment = { id = "CABC123456789012345678901234567890123456789012345678901234", version = "1.0.0", deployed_at = 12345 }
vesting_escrow = { id = "CDEF123456789012345678901234567890123456789012345678901234", version = "1.0.0", deployed_at = 12346 }
revenue_split = { id = "CGHI123456789012345678901234567890123456789012345678901234", version = "1.0.0", deployed_at = 12347 }
cross_asset_payment = { id = "CJKL123456789012345678901234567890123456789012345678901234", version = "1.0.0", deployed_at = 12348 }
[production.contracts]
bulk_payment = { id = "CXYZ123456789012345678901234567890123456789012345678901234", version = "1.0.0", deployed_at = 54321 }
# ... add mainnet contractscd backend
npm install # if not already done
npm run dev# Option 1: Use curl
curl http://localhost:3000/api/contracts | jq
# Option 2: Use the test script
./test-contract-endpoint.shimport { useEffect, useState } from 'react';
import { contractService } from './services/contracts';
function MyComponent() {
const [contractId, setContractId] = useState<string | null>(null);
useEffect(() => {
// Get contract ID for bulk_payment on testnet
const id = contractService.getContractId('bulk_payment', 'testnet');
setContractId(id);
}, []);
return <div>Contract: {contractId}</div>;
}const registry = contractService.getAllContracts();
console.log(`Found ${registry?.count} contracts`);await contractService.refreshRegistry();- Add to
environments.toml:
[staging.contracts]
my_new_contract = { id = "CNEW...", version = "1.0.0", deployed_at = 99999 }- Use in frontend:
const contractId = contractService.getContractId("my_new_contract", "testnet");That's it! No code changes needed.
- Full API Docs:
docs/CONTRACT_REGISTRY_API.md - Implementation Details:
CONTRACT_REGISTRY_IMPLEMENTATION.md - Usage Examples:
frontend/src/services/contracts.example.tsx - Summary:
IMPLEMENTATION_SUMMARY.md
- Backend server running:
curl http://localhost:3000/health - Contracts endpoint:
curl http://localhost:3000/api/contracts - Frontend console: Should see "Contract registry fetched successfully"
No contracts returned?
- Check
environments.tomlis in project root - Verify contract IDs start with 'C' and are 57 characters long
- Check backend logs for parsing errors
Frontend not fetching?
- Verify
VITE_API_BASE_URLenvironment variable - Check browser console for errors
- Ensure backend is running
Cache not refreshing?
- Cache TTL is 1 hour
- Manually refresh:
contractService.refreshRegistry() - Restart frontend to clear cache