Overview
Learn how to interact with ZKScore smart contracts directly using Web3 libraries like ethers.js, web3.js, or viem.Prerequisites
- Web3 Library: ethers.js, web3.js, or viem
- Contract Addresses: ZKScore contract addresses
- ABI Files: Contract Application Binary Interfaces
- RPC Provider: Ethereum RPC endpoint
Basic Setup
Import Libraries
Contract Configuration
Identity SBT Interactions
Check Identity Status
Mint Identity
Score Calculator Interactions
Get User Score
Listen to Score Updates
Achievement Registry Interactions
Get User Achievements
Claim Achievement
Trust Registry Interactions
Create Attestation
Get Attestations
Error Handling
Common Error Patterns
Gas Optimization
Gas Estimation
Batch Transactions
Best Practices
- Always Estimate Gas: Estimate gas before transactions
- Handle Errors Gracefully: Implement comprehensive error handling
- Use Events: Listen to contract events for real-time updates
- Batch Operations: Combine multiple calls when possible
- Monitor Gas Prices: Use appropriate gas prices for network conditions