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.
Overview
ZKScore is a decentralized reputation system that calculates on-chain reputation scores across multiple categories. This guide will help you get started with ZKScore.
What is ZKScore?
ZKScore aggregates on-chain activity across 8 categories to create a comprehensive reputation score (0-1000):
- DeFi (20%): Lending, borrowing, liquidity provision
- NFT (15%): Trading, collecting, creation
- Social (10%): Community engagement
- Trading (20%): Trading performance
- Governance (10%): DAO participation
- Gaming (10%): Gaming achievements
- Identity (10%): Verification level
- Trust (5%): Attestations received
Quick Start
1. Get an API Key
- Visit app.onzks.com
- Connect your wallet
- Create an API key
- Copy your API key for use in applications
2. Install SDK
3. Basic Usage
import { ZKScoreClient } from '@zkscore/sdk';
const client = new ZKScoreClient({
apiKey: 'your_api_key_here',
environment: 'mainnet'
});
// Get user score
const score = await client.getScore('alice.zks');
console.log('Score:', score.total);
// Get score breakdown
const breakdown = await client.getScoreBreakdown('alice.zks');
console.log('DeFi score:', breakdown.defi);
Identity System
ZKS IDs
ZKScore uses human-readable identifiers called ZKS IDs (e.g., alice.zks) that automatically resolve to wallet addresses.
Minting Identity
// Check if ZKS ID is available
const isAvailable = await client.checkZKSIdAvailability('alice.zks');
console.log('Available:', isAvailable);
// Mint identity (requires wallet connection)
const result = await client.mintIdentity({
zksId: 'alice.zks',
displayName: 'Alice Smith',
avatarUrl: 'https://example.com/avatar.jpg'
});
console.log('Identity minted:', result.transactionHash);
Activating Identity
// Activate identity to enable full functionality
const result = await client.activateIdentity();
console.log('Identity activated:', result.transactionHash);
Score System
Getting Scores
// Get total score
const score = await client.getScore('alice.zks');
console.log('Total score:', score.total);
// Get detailed breakdown
const breakdown = await client.getScoreBreakdown('alice.zks');
console.log('Category scores:', breakdown);
// Get score history
const history = await client.getScoreHistory('alice.zks');
console.log('Score history:', history);
Score Categories
const breakdown = await client.getScoreBreakdown('alice.zks');
console.log('DeFi Score:', breakdown.defi);
console.log('NFT Score:', breakdown.nft);
console.log('Social Score:', breakdown.social);
console.log('Trading Score:', breakdown.trading);
console.log('Governance Score:', breakdown.governance);
console.log('Gaming Score:', breakdown.gaming);
console.log('Identity Score:', breakdown.identity);
console.log('Trust Score:', breakdown.trust);
Achievement System
Getting Achievements
// Get user achievements
const achievements = await client.getAchievements('alice.zks');
console.log('Achievements:', achievements);
// Get available achievements
const available = await client.listAchievements();
console.log('Available achievements:', available);
Claiming Achievements
// Check if user can claim achievement
const canClaim = await client.canClaimAchievement('alice.zks', 'achievement-id');
if (canClaim) {
const result = await client.claimAchievement('alice.zks', 'achievement-id');
console.log('Achievement claimed:', result.transactionHash);
}
Trading Data
Trading Statistics
// Get trading stats
const stats = await client.getTradingStats('alice.zks');
console.log('Total volume:', stats.totalVolume);
console.log('Win rate:', stats.winRate);
// Get trading history
const history = await client.getTradingHistory('alice.zks');
console.log('Trading history:', history);
Trading Leaderboard
// Get trading leaderboard
const leaderboard = await client.getTradingLeaderboard({
period: '30d',
limit: 100
});
console.log('Top traders:', leaderboard);
Trust Layer
Attestations
// Get user attestations
const attestations = await client.getAttestations('alice.zks');
console.log('Attestations:', attestations);
// Create attestation
const result = await client.createAttestation({
recipient: 'bob.zks',
schema: 'skill-verification',
data: {
skill: 'Solidity Development',
level: 5
}
});
console.log('Attestation created:', result.transactionHash);
Error Handling
Common Errors
try {
const score = await client.getScore('alice.zks');
console.log('Score:', score.total);
} catch (error) {
if (error.code === 'IDENTITY_NOT_FOUND') {
console.error('User has no identity');
} else if (error.code === 'SCORE_NOT_FOUND') {
console.error('User has no score yet');
} else {
console.error('Error:', error.message);
}
}
Best Practices
- Always Handle Errors: Implement proper error handling
- Use ZKS IDs: Prefer ZKS IDs over wallet addresses
- Cache Data: Cache frequently accessed data
- Monitor Rate Limits: Stay within API rate limits
- Test Thoroughly: Test with different user scenarios
Next Steps