Skip to main content

Overview

This document provides a comprehensive reference for all functions available in the ZKScore Trust Registry contract. Each function includes detailed parameter descriptions, return values, gas estimates, and usage examples.
All functions that modify state require a transaction and will consume gas. View functions are free to call and return data immediately.

Attestation Functions

attest

Create a new attestation for a recipient.
Parameters:
  • request (AttestationRequest): Attestation request data
    • schema (bytes32): Schema identifier
    • data (AttestationRequestData): Attestation data
      • recipient (address): Attestation recipient
      • expirationTime (uint64): Expiration timestamp (0 = no expiration)
      • revocable (bool): Whether attestation can be revoked
      • refUID (bytes32): Reference to another attestation
      • data (bytes): Encoded attestation data
Returns:
  • bytes32: Unique attestation ID (UID)
Gas Estimate: ~120,000 gas Events Emitted:
  • Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema)
Example Usage:

multiAttest

Create multiple attestations in a single transaction.
Parameters:
  • requests (MultiAttestationRequest[]): Array of attestation requests
    • schema (bytes32): Schema identifier
    • data (AttestationRequestData[]): Array of attestation data
Returns:
  • bytes32[]: Array of attestation UIDs
Gas Estimate: ~100,000 + (120,000 × number of attestations) Example Usage:

revoke

Revoke an existing attestation.
Parameters:
  • request (RevocationRequest): Revocation request data
    • schema (bytes32): Schema identifier
    • data (RevocationRequestData): Revocation data
      • uid (bytes32): Attestation UID to revoke
      • value (uint256): ETH value (if required by schema)
Returns: None Gas Estimate: ~40,000 gas Requirements:
  • Caller must be the attester
  • Attestation must be revocable
  • Attestation must not already be revoked
Events Emitted:
  • Revoked(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema)
Example Usage:

Query Functions

getAttestation

Get detailed information about an attestation.
Parameters:
  • uid (bytes32): Attestation unique identifier
Returns:
  • Attestation: Complete attestation data
Gas Estimate: ~5,000 gas (view function) Example Usage:

isAttestationValid

Check if an attestation is currently valid.
Parameters:
  • uid (bytes32): Attestation UID
Returns:
  • bool: True if valid, false otherwise
Gas Estimate: ~3,000 gas (view function)

getReceivedAttestationUIDs

Get all attestation UIDs received by an address.
Parameters:
  • recipient (address): Attestation recipient
  • schema (bytes32): Schema filter (0 = all schemas)
  • start (uint256): Starting index
  • length (uint256): Number of results
  • reverseOrder (bool): Return in reverse chronological order
Returns:
  • bytes32[]: Array of attestation UIDs
Gas Estimate: ~5,000 + (500 × number of results) (view function)

getSentAttestationUIDs

Get all attestation UIDs sent by an address.
Parameters:
  • attester (address): Attestation sender
  • schema (bytes32): Schema filter
  • start (uint256): Starting index
  • length (uint256): Number of results
  • reverseOrder (bool): Return in reverse order
Returns:
  • bytes32[]: Array of attestation UIDs
Gas Estimate: ~5,000 + (500 × number of results) (view function)

Schema Functions

registerSchema

Register a new attestation schema.
Parameters:
  • schema (string): Schema definition (e.g., “bool verified,uint256 level”)
  • resolver (ISchemaResolver): Schema resolver contract (0 = no resolver)
  • revocable (bool): Whether attestations are revocable
Returns:
  • bytes32: Schema UID
Gas Estimate: ~80,000 gas Events Emitted:
  • SchemaRegistered(bytes32 indexed uid, address indexed registerer)
Example Usage:

getSchema

Get schema information.
Parameters:
  • uid (bytes32): Schema UID
Returns:
  • SchemaRecord: Schema data including definition, resolver, and revocability
Gas Estimate: ~3,000 gas (view function)

Trust Module Functions

evaluateTrust

Evaluate trust score for a subject using a specific module.
Parameters:
  • module (address): Trust module contract address
  • subject (address): Address to evaluate
  • context (bytes): Module-specific context data
Returns:
  • uint256: Trust score (0-1000)
Gas Estimate: Varies by module (~10,000-50,000 gas)

registerTrustModule

Register a new trust evaluation module.
Parameters:
  • module (address): Module contract address
  • name (string): Module name
Returns: None Gas Estimate: ~60,000 gas Requirements:
  • Caller must have MODULE_REGISTRAR_ROLE
  • Module must implement ITrustModule interface

Error Handling

Common Errors

Error Handling Example

Gas Optimization Tips

Batch Attestations

Optimize Data Encoding