Developer Guide
Getting Started
Installation and Setup
Install the required packages for Self Connect integration:
npm install @celo/identity @celo/abis viemRequired Packages
@celo/identity
ODIS integration and identifier utilities
@celo/abis
Contract ABIs for FederatedAttestations
viem
Modern Ethereum library for blockchain interactions
Why Viem?
Self Connect uses Viem as the recommended library for blockchain interactions because:
Modern & Type-Safe: Built with TypeScript for excellent type inference
Lightweight: Smaller bundle size compared to legacy libraries
Modular: Import only what you need
Better DX: Cleaner API and better error messages
Active Maintenance: Well-maintained with regular updates
EIP-1193 Support: Native support for wallet providers
Note: ContractKit is deprecated and no longer recommended for new projects.
Network Configuration
Mainnet:
Alfajores Testnet:
Becoming an Issuer
Issuer Setup
An issuer needs:
A funded wallet account
ODIS quota for identifier obfuscation
Verification infrastructure
Optional: Data Encryption Key (DEK) for enhanced authentication
Step 1: Set Up Issuer Account
Step 2: Authentication Methods
Self Connect supports multiple authentication methods for ODIS:
Wallet Key Authentication
Encryption Key (DEK) Authentication
Step 3: Configure ODIS Service Context
ODIS Quota Management
Check Current Quota
Purchase Quota
Verification Responsibilities
As an issuer, you must verify user ownership of identifiers. Implementation depends on identifier type:
Phone Number Verification
Twitter Verification
Email Verification
SDK Integration with Viem
Complete Registration Example
Complete Lookup Example
Viem Best Practices
Use Type-Safe Contract Interactions
Handle Hex Types Properly
Viem uses strict Hex types for type safety:
Use Proper Error Handling
Optimize with Public Actions
For read-only operations, use public client directly:
Web/Browser
Browser environments require careful handling of wallet connections:
Next.js Example:
Custom Identifier Types
Create custom identifier types for your use case:
Best Practices for Custom Identifiers:
Use descriptive prefixes (e.g.,
myapp://notma://)Document your prefix for ecosystem adoption
Consider standardization if widely applicable
Ensure identifiers are unique and verifiable
Reference & Resources
Contract Addresses
Mainnet (Celo)
FederatedAttestations
0x0aD5b1d0C25ecF6266Dd951403723B2687d6aff2
OdisPayments
0x645170cdB6B5c1bc80847bb728dBa56C50a20a49
StableToken (cUSD)
0x765DE816845861e75A25fCA122bb6898B8B1282a
Alfajores Testnet
FederatedAttestations
0x70F9314aF173c246669cFb0EEe79F9Cfd9C34ee3
OdisPayments
0x645170cdB6B5c1bc80847bb728dBa56C50a20a49
StableToken (cUSD)
0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1
Example Repositories
Troubleshooting
ODIS Quota Issues
Problem: "Insufficient quota" error
Solution:
Rate Limiting
Problem: Too many requests to ODIS
Solution:
Implement request queuing
Cache obfuscated identifiers
Use batch operations when possible
Monitor quota usage
Transaction Failures
Problem: "Transaction reverted" or gas estimation failed
Solution:
Network Issues
Problem: RPC connection failures
Solution:
FAQ
Q: Do I need to pay gas for lookups?
A: No, lookups are read-only operations that don't require gas. You only need ODIS quota.
Q: Can users register themselves?
A: Users can submit the registration transaction if the issuer provides a signed attestation, but the issuer must still verify ownership and provide the obfuscated identifier.
Q: How much does it cost to register a user?
A: With 10 cUSD of ODIS quota, you can register 10,000 users. Gas costs for on-chain registration are typically <0.01 cUSD per transaction.
Q: Can I trust attestations from any issuer?
A: No, you should only trust issuers whose verification standards you trust. Each issuer is responsible for their own verification quality.
Q: What happens if an issuer goes offline?
A: Existing attestations remain on-chain and accessible. Users can register with other issuers for redundancy.
Q: Can I verify multiple identifier types for the same user?
A: Yes, you can register multiple attestations (phone + Twitter + email) for the same address, each with its own prefix.
Q: Is E.164 format required for phone numbers?
A: Yes, the SDK's getObfuscatedIdentifier function only accepts E.164 formatted phone numbers (e.g., +12345678901).
Q: How do I map attestation results to issuers?
A: The lookupAttestations return arrays are ordered by the trustedIssuers input array. Use countsPerIssuer to determine how many attestations belong to each issuer.
Q: Can I use Self Connect on other EVM chains?
A: Self Connect is currently designed for Celo. The contracts and ODIS infrastructure are Celo-specific.
Q: Why use Viem instead of Web3.js or Ethers.js?
A: Viem offers better TypeScript support, smaller bundle size, modular architecture, and is actively maintained. It's the recommended library for modern Web3 development on Celo.
Q: Do I need to use different RPC endpoints for mainnet vs testnet?
A: Yes, Viem's chain configurations handle this automatically:
Mainnet: Use
celochain fromviem/chainsTestnet: Use
celoAlfajoreschain fromviem/chains
Last updated