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 Smart Contracts?
ZKScore smart contracts provide the foundational infrastructure for on-chain identity, reputation scoring, achievements, and trust systems. Built on Ethereum and compatible with all EVM chains.
IdentitySBT Soulbound identity NFTs for unique user identification
ScoreCalculator On-chain reputation scoring engine
AchievementRegistry Achievement system and NFT badges
TrustRegistry Attestation and trust verification system
ProtocolRegistry Protocol integration and module management
Contract Architecture
Core Contracts
IdentitySBT Contract
Non-transferable identity NFTs that represent unique individuals:
// Mint a new identity
function mint ( address to , string calldata username ) external returns ( uint256 );
// Activate an identity
function activate ( uint256 tokenId ) external ;
// Check if address has identity
function hasIdentity ( address account ) external view returns ( bool );
Key Features:
Soulbound (non-transferable) NFTs
Unique username system
Activation mechanism
Metadata management
ScoreCalculator Contract
On-chain reputation scoring with real-time updates:
// Get current score
function getScore ( address account ) external view returns ( uint256 );
// Get score breakdown
function getScoreBreakdown ( address account ) external view returns ( ScoreBreakdown memory );
// Update score (called by authorized updaters)
function updateScore ( address account , uint256 newScore ) external ;
Key Features:
Real-time score calculation
Multi-dimensional scoring
Historical score tracking
Authorized updater system
AchievementRegistry Contract
Gamified achievement system with NFT rewards:
// Create new achievement
function createAchievement (
string calldata name ,
string calldata description ,
uint256 points
) external returns ( uint256 );
// Claim achievement
function claimAchievement ( uint256 achievementId ) external ;
// Get user achievements
function getUserAchievements ( address user ) external view returns ( uint256 [] memory );
Key Features:
Custom achievement creation
NFT badge rewards
Progress tracking
Point system
TrustRegistry Contract
Flexible attestation system for building trust:
// Create attestation
function createAttestation (
address subject ,
string calldata schema ,
bytes calldata data
) external returns ( uint256 );
// Revoke attestation
function revokeAttestation ( uint256 attestationId ) external ;
// Get attestations for subject
function getAttestations ( address subject ) external view returns ( Attestation [] memory );
Key Features:
Schema-based attestations
Revocable attestations
Multi-signature support
Time-bound attestations
ProtocolRegistry Contract
Integration hub for protocols and modules:
// Register protocol
function registerProtocol (
string calldata name ,
address protocolAddress ,
bytes calldata metadata
) external ;
// Get protocol info
function getProtocol ( string calldata name ) external view returns ( Protocol memory );
// Update protocol
function updateProtocol ( string calldata name , address newAddress ) external ;
Integration Examples
Direct Contract Integration
import { ethers } from 'ethers' ;
import { IdentitySBT__factory } from '@zkscore/contracts' ;
const provider = new ethers . providers . JsonRpcProvider ( RPC_URL );
const signer = provider . getSigner ();
const identitySBT = IdentitySBT__factory . connect (
'0x...' , // Contract address
signer
);
// Mint identity
const tx = await identitySBT . mint ( '0x742d35...' , 'alice' );
await tx . wait ();
Ethers.js Integration
import { ethers } from 'ethers' ;
import { ZKScoreContracts } from '@zkscore/contracts' ;
const contracts = new ZKScoreContracts ( provider , signer );
// Mint identity
await contracts . identity . mint ( '0x742d35...' , 'alice' );
// Get score
const score = await contracts . scores . getScore ( '0x742d35...' );
// Create attestation
await contracts . trust . createAttestation (
'0x742d35...' ,
'kyc-verification' ,
{ verified: true , level: 'tier-2' }
);
Viem Integration
import { createPublicClient , createWalletClient } from 'viem' ;
import { zkScoreAbi } from '@zkscore/contracts' ;
const publicClient = createPublicClient ({
chain: mainnet ,
transport: http (),
});
const walletClient = createWalletClient ({
chain: mainnet ,
transport: http (),
});
// Read score
const score = await publicClient . readContract ({
address: '0x...' ,
abi: zkScoreAbi ,
functionName: 'getScore' ,
args: [ '0x742d35...' ],
});
// Mint identity
await walletClient . writeContract ({
address: '0x...' ,
abi: identitySbtAbi ,
functionName: 'mint' ,
args: [ '0x742d35...' , 'alice' ],
});
Wagmi Integration
import { useContract , useContractWrite } from 'wagmi' ;
import { zkScoreConfig } from '@zkscore/contracts' ;
function MintIdentity () {
const { write } = useContractWrite ({
address: zkScoreConfig . identitySbt ,
abi: identitySbtAbi ,
functionName: 'mint' ,
});
return (
< button onClick = { () => write ({ args: [ '0x742d35...' , 'alice' ] }) } >
Mint Identity
</ button >
);
}
Network Deployments
Ethereum Mainnet IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
Base IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
Polygon IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
Arbitrum IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
Optimism IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
BSC IdentitySBT : 0x...
ScoreCalculator : 0x...
AchievementRegistry : 0x...
Security Features
Access Control Role-based permissions and multi-sig support
Upgradeable Proxy patterns for contract upgrades
Pausable Emergency pause functionality
Audited Comprehensive security audits
Gas Optimization
Batch Operations : Combine multiple calls in single transaction
Storage Optimization : Efficient data structures
Event Optimization : Minimal event emissions
Proxy Patterns : Upgradeable without migration
Testing
Hardhat Integration
import { ethers } from 'hardhat' ;
import { ZKScoreContracts } from '@zkscore/contracts' ;
describe ( 'ZKScore Contracts' , () => {
let contracts : ZKScoreContracts ;
beforeEach ( async () => {
contracts = await ZKScoreContracts . deploy ();
});
it ( 'should mint identity' , async () => {
await contracts . identity . mint ( '0x742d35...' , 'alice' );
const hasIdentity = await contracts . identity . hasIdentity ( '0x742d35...' );
expect ( hasIdentity ). to . be . true ;
});
});
Foundry Integration
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0 ;
import "forge-std/Test.sol" ;
import "../src/IdentitySBT.sol" ;
contract IdentitySBTTest is Test {
IdentitySBT identitySBT;
function setUp () public {
identitySBT = new IdentitySBT ();
}
function testMintIdentity () public {
identitySBT. mint ( address ( this ), "alice" );
assertTrue (identitySBT. hasIdentity ( address ( this )));
}
}
Event Monitoring
// Listen for identity minted events
const filter = identitySBT . filters . IdentityMinted ();
identitySBT . on ( filter , ( to , tokenId , username , event ) => {
console . log ( `Identity minted: ${ username } ( ${ tokenId } ) to ${ to } ` );
});
// Listen for score updates
const scoreFilter = scoreCalculator . filters . ScoreUpdated ();
scoreCalculator . on ( scoreFilter , ( account , newScore , oldScore , event ) => {
console . log ( `Score updated for ${ account } : ${ oldScore } → ${ newScore } ` );
});
Best Practices
Error Handling Always check return values and handle reverts
Gas Estimation Estimate gas before transactions
Event Listening Monitor events for state changes
Batch Operations Combine multiple calls when possible
Common Patterns
Identity Verification
async function verifyIdentity ( address : string ) : Promise < boolean > {
try {
const hasIdentity = await identitySBT . hasIdentity ( address );
if ( ! hasIdentity ) return false ;
const tokenId = await identitySBT . getTokenId ( address );
const isActive = await identitySBT . isActive ( tokenId );
return isActive ;
} catch ( error ) {
console . error ( 'Identity verification failed:' , error );
return false ;
}
}
Score Gating
async function checkScoreGate ( address : string , minScore : number ) : Promise < boolean > {
try {
const score = await scoreCalculator . getScore ( address );
return score >= minScore ;
} catch ( error ) {
console . error ( 'Score check failed:' , error );
return false ;
}
}
Achievement Tracking
async function trackAchievementProgress ( address : string , achievementId : number ) {
const progress = await achievementRegistry . getProgress ( address , achievementId );
const isEligible = await achievementRegistry . isEligible ( address , achievementId );
return { progress , isEligible };
}
Next Steps
Choose Integration Method
Start Building
Integrate contracts into your application
Examples →
Test Thoroughly
Use our testing utilities and examples
Testing →
Support & Resources
Contract Addresses All deployed contract addresses
ABI Files Contract ABI files
GitHub Source code and issues
Discord Developer community