Documentation Index Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
Use this file to discover all available pages before exploring further.
What are ZKScore SDKs?
ZKScore SDKs provide easy-to-use libraries for integrating reputation scores, identity management, achievements, and trust systems into your applications. Available for JavaScript, TypeScript, and React.
JavaScript SDK Full-featured SDK for Node.js and browser applications
React SDK React hooks and components for building user interfaces
Key Features
🔐 Identity Management
Create and manage ZKScore identities with simple API calls:
import { ZKScoreSDK } from '@zkscore/sdk' ;
const sdk = new ZKScoreSDK ({ apiKey: 'your-api-key' });
// Create identity
const identity = await sdk . identity . mint ({
address: '0x742d35...' ,
username: 'alice' ,
});
// Get identity
const userIdentity = await sdk . identity . getIdentity ( '0x742d35...' );
📊 Reputation Scoring
Access comprehensive reputation scores and analytics:
// Get overall score
const score = await sdk . scores . getScore ( '0x742d35...' );
// Get detailed breakdown
const breakdown = await sdk . scores . getBreakdown ( '0x742d35...' );
// Get score history
const history = await sdk . scores . getHistory ( '0x742d35...' );
🏆 Achievement System
Track and manage user achievements:
// List all achievements
const achievements = await sdk . achievements . listAchievements ();
// Get user achievements
const userAchievements = await sdk . achievements . getUserAchievements ( '0x742d35...' );
// Claim achievement
await sdk . achievements . claim ({
achievementId: 'defi-expert' ,
proof: zkProof ,
});
🔒 Zero-Knowledge Proofs
Generate privacy-preserving proofs:
// Generate score proof
const proof = await sdk . zkProofs . generate ({
address: '0x742d35...' ,
type: 'score-threshold' ,
threshold: 700 ,
hideExactScore: true ,
});
// Verify proof
const isValid = await sdk . zkProofs . verify ( proof );
✅ Trust Layer
Create and manage attestations:
// Create attestation
const attestation = await sdk . trustLayer . createAttestation ({
subject: '0x742d35...' ,
schema: 'kyc-verification' ,
data: { verified: true , level: 'tier-2' },
});
// Get attestations
const attestations = await sdk . trustLayer . getAttestations ( '0x742d35...' );
React Integration
Using React? We have hooks for everything:
import { useScore , useIdentity , useAchievements } from '@zkscore/react' ;
function UserProfile ({ address } : { address : string }) {
const { identity } = useIdentity ( address );
const { score } = useScore ( address );
const { achievements } = useAchievements ( address );
return (
< div >
< h1 > { identity ?. username || 'Anonymous' } </ h1 >
< p > Score: { score ?. overall } /1000 </ p >
< p > Achievements: { achievements ?. length || 0 } </ p >
</ div >
);
}
Installation
npm install @zkscore/sdk @zkscore/react
Quick Start
Get your API key from the Builder Portal
Install the SDK in your project
Initialize with your API key
Start building trust-enabled applications
import { ZKScoreSDK } from '@zkscore/sdk' ;
const sdk = new ZKScoreSDK ({
apiKey: process . env . ZKSCORE_API_KEY ,
network: 'mainnet' ,
});
// Get a user's score
const score = await sdk . scores . getScore ( '0x742d35...' );
console . log ( `Score: ${ score . overall } /1000` );
SDK Architecture
Node.js Full server-side support
Browser Client-side applications
Vue.js Vue.js applications
TypeScript Support
All SDKs are built with TypeScript and provide full type safety:
import { ZKScoreSDK } from '@zkscore/sdk' ;
import type { Score , Identity , Achievement } from '@zkscore/types' ;
const sdk = new ZKScoreSDK ({ apiKey: 'your-key' });
// Fully typed responses
const score : Score = await sdk . scores . getScore ( '0x742d35...' );
const identity : Identity = await sdk . identity . getIdentity ( '0x742d35...' );
Error Handling
Comprehensive error handling with detailed error codes:
try {
const score = await sdk . scores . getScore ( address );
} catch ( error ) {
if ( error . code === 'IDENTITY_NOT_FOUND' ) {
console . log ( 'User needs to create an identity first' );
} else if ( error . code === 'RATE_LIMIT_EXCEEDED' ) {
console . log ( 'Too many requests, please wait' );
}
}
Built-in caching and performance optimizations:
const sdk = new ZKScoreSDK ({
apiKey: 'your-key' ,
cacheTime: 300000 , // 5 minutes
retryAttempts: 3 ,
});
// Automatic caching
const score1 = await sdk . scores . getScore ( address ); // API call
const score2 = await sdk . scores . getScore ( address ); // Cached
TypeScript Definitions Full TypeScript support with IntelliSense
Error Codes Comprehensive error handling
Debug Mode Detailed logging and debugging
Mock Data Testing utilities and mock data
Common Use Cases
Score-Gated Access
async function checkAccess ( userAddress : string , minScore : number ) {
const score = await sdk . scores . getScore ( userAddress );
return score . overall >= minScore ;
}
Achievement Tracking
async function trackProgress ( userAddress : string ) {
const achievements = await sdk . achievements . getUserAchievements ( userAddress );
const progress = await sdk . achievements . getProgress ( userAddress , 'defi-expert' );
return { earned: achievements . length , progress };
}
Privacy-Preserving Verification
async function verifyWithPrivacy ( userAddress : string ) {
const proof = await sdk . zkProofs . generate ({
address: userAddress ,
type: 'score-threshold' ,
threshold: 700 ,
hideExactScore: true ,
});
return sdk . zkProofs . verify ( proof );
}
Best Practices
API Key Security Never expose API keys in client-side code
Error Handling Always handle errors gracefully
Caching Use appropriate cache times for your use case
Rate Limiting Respect API rate limits
Migration Guide
From v1 to v2
// v1 (deprecated)
const client = new ZKScoreClient ( apiKey );
const score = await client . getScore ( address );
// v2 (current)
const sdk = new ZKScoreSDK ({ apiKey });
const score = await sdk . scores . getScore ( address );
GitHub Source code and issues
Discord Developer community
Documentation Complete documentation
Examples Code examples and tutorials
Next Steps