Skip to main content

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

  1. Always Estimate Gas: Estimate gas before transactions
  2. Handle Errors Gracefully: Implement comprehensive error handling
  3. Use Events: Listen to contract events for real-time updates
  4. Batch Operations: Combine multiple calls when possible
  5. Monitor Gas Prices: Use appropriate gas prices for network conditions