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.Standard ERC-721 Events
Transfer
Emitted when a token is transferred from one address to another.from(address indexed): The previous owner of the tokento(address indexed): The new owner of the tokentokenId(uint256 indexed): The ID of the token
- When a token is minted (
fromis zero address) - When a token is transferred between addresses
- When a token is burned (
tois zero address)
Approval
Emitted when an address is approved to transfer a specific token.owner(address indexed): The owner of the tokenapproved(address indexed): The approved addresstokenId(uint256 indexed): The ID of the token
- When
approve()is called - When approval is revoked (approved address is zero)
ApprovalForAll
Emitted when an operator is approved or revoked for all tokens.owner(address indexed): The owner of the tokensoperator(address indexed): The operator addressapproved(bool): True if approved, false if revoked
- When
setApprovalForAll()is called
Soulbound Token Events
IdentityMinted
Emitted when a new identity token is minted.to(address indexed): The address the token was minted totokenId(uint256 indexed): The ID of the minted tokenname(string): The ZKS ID name
- When
mint()is called successfully
IdentityActivated
Emitted when an identity token is activated (made soulbound).tokenId(uint256 indexed): The ID of the activated tokenowner(address indexed): The owner of the token
- When
activate()is called successfully
MetadataUpdated
Emitted when a token’s metadata URI is updated.tokenId(uint256 indexed): The ID of the tokennewURI(string): The new metadata URI
- When
setTokenURI()is called successfully
SoulboundStatusChanged
Emitted when a token’s soulbound status changes.tokenId(uint256 indexed): The ID of the tokenisSoulbound(bool): True if the token is now soulbound, false otherwise
- 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
- Always handle errors: Event listeners can fail, implement proper error handling
- Use filters efficiently: Filter events by indexed parameters when possible
- Monitor gas costs: Event queries can be expensive for large ranges
- Implement rate limiting: Don’t overwhelm your application with too many events
- Store event data: Consider storing important event data in a database
Performance Optimization
- Use indexed parameters: Filter by indexed parameters for better performance
- Limit block ranges: Query smaller block ranges to avoid timeouts
- Cache results: Cache frequently accessed event data
- Use pagination: Implement pagination for large event datasets
- Monitor memory usage: Large event queries can consume significant memory
Related Documentation
- Contract Overview - Contract architecture and features
- Functions Reference - Complete function documentation
- Integration Guide - Integration examples
- Security Guide - Security considerations
- Deployment Guide - Deployment instructions