Skip to main content

Overview

The ZKScore Identity SBT contract emits events for all significant state changes. These events are essential for tracking identity lifecycle, monitoring contract activity, and building off-chain applications.
Events are stored in the blockchain and can be queried by indexers. They provide a reliable way to track contract state changes and build real-time applications.

Standard ERC-721 Events

Transfer

Emitted when a token is transferred from one address to another.
Parameters:
  • from (address indexed): The previous owner of the token
  • to (address indexed): The new owner of the token
  • tokenId (uint256 indexed): The ID of the token
When Emitted:
  • When a token is minted (from is zero address)
  • When a token is transferred between addresses
  • When a token is burned (to is zero address)
Note: This event is not emitted for activated (soulbound) tokens since they cannot be transferred. Example Usage:

Approval

Emitted when an address is approved to transfer a specific token.
Parameters:
  • owner (address indexed): The owner of the token
  • approved (address indexed): The approved address
  • tokenId (uint256 indexed): The ID of the token
When Emitted:
  • When approve() is called
  • When approval is revoked (approved address is zero)
Note: This event is not emitted for activated (soulbound) tokens since they cannot be transferred.

ApprovalForAll

Emitted when an operator is approved or revoked for all tokens.
Parameters:
  • owner (address indexed): The owner of the tokens
  • operator (address indexed): The operator address
  • approved (bool): True if approved, false if revoked
When Emitted:
  • When setApprovalForAll() is called

Soulbound Token Events

IdentityMinted

Emitted when a new identity token is minted.
Parameters:
  • to (address indexed): The address the token was minted to
  • tokenId (uint256 indexed): The ID of the minted token
  • name (string): The ZKS ID name
When Emitted:
  • When mint() is called successfully
Example Usage:

IdentityActivated

Emitted when an identity token is activated (made soulbound).
Parameters:
  • tokenId (uint256 indexed): The ID of the activated token
  • owner (address indexed): The owner of the token
When Emitted:
  • When activate() is called successfully
Example Usage:

MetadataUpdated

Emitted when a token’s metadata URI is updated.
Parameters:
  • tokenId (uint256 indexed): The ID of the token
  • newURI (string): The new metadata URI
When Emitted:
  • When setTokenURI() is called successfully
Note: This event is not emitted for activated tokens since their metadata is immutable.

SoulboundStatusChanged

Emitted when a token’s soulbound status changes.
Parameters:
  • tokenId (uint256 indexed): The ID of the token
  • isSoulbound (bool): True if the token is now soulbound, false otherwise
When Emitted:
  • When activate() is called (isSoulbound becomes true)
  • When soulbound status is changed by admin (rare)

Event Indexing

Indexed Parameters

Events have up to 3 indexed parameters that can be filtered efficiently:

Filtering Examples

Event Monitoring

Real-time Monitoring

Historical Event Queries

Event Analytics

Event Statistics

Best Practices

Event Handling

  1. Always handle errors: Event listeners can fail, implement proper error handling
  2. Use filters efficiently: Filter events by indexed parameters when possible
  3. Monitor gas costs: Event queries can be expensive for large ranges
  4. Implement rate limiting: Don’t overwhelm your application with too many events
  5. Store event data: Consider storing important event data in a database

Performance Optimization

  1. Use indexed parameters: Filter by indexed parameters for better performance
  2. Limit block ranges: Query smaller block ranges to avoid timeouts
  3. Cache results: Cache frequently accessed event data
  4. Use pagination: Implement pagination for large event datasets
  5. Monitor memory usage: Large event queries can consume significant memory