Skip to main content

Overview

The ZKScore Score Calculator contract emits events for all significant score changes and configuration updates. These events are essential for tracking score evolution, monitoring calculation activity, and building real-time applications.
Events are stored on the blockchain and can be efficiently queried by indexers. They provide a reliable audit trail for all score changes and system updates.

Score Events

ScoreCalculated

Emitted when a new score is calculated for a user.
Parameters:
  • user (address indexed): The user whose score was calculated
  • totalScore (uint256): The calculated total score (0-1000)
  • timestamp (uint256): Block timestamp of calculation
When Emitted:
  • When calculateScore() is called
  • During batch score calculations
  • When scores are automatically refreshed
Example Usage:

ScoreUpdated

Emitted when a user’s score changes.
Parameters:
  • user (address indexed): The user whose score changed
  • oldScore (uint256): Previous score value
  • newScore (uint256): New score value
When Emitted:
  • When score recalculation results in a different value
  • After category score updates
  • During manual score refreshes
Example Usage:

CategoryScoreUpdated

Emitted when a category score is updated.
Parameters:
  • user (address indexed): The user whose category score was updated
  • category (uint8 indexed): Category index (0-7)
  • score (uint256): New category score (0-1000)
Category Mapping:
  • 0: DeFi
  • 1: NFT
  • 2: Social
  • 3: Trading
  • 4: Governance
  • 5: Gaming
  • 6: Identity
  • 7: Trust
When Emitted:
  • When updateCategoryScore() is called
  • During batch category updates
  • When individual category recalculation occurs
Example Usage:

Configuration Events

CategoryWeightUpdated

Emitted when a category weight is changed.
Parameters:
  • category (uint8 indexed): Category index (0-7)
  • oldWeight (uint256): Previous weight in basis points
  • newWeight (uint256): New weight in basis points
When Emitted:
  • When updateCategoryWeight() is called
  • During batch weight updates
  • When category weights are reconfigured
Example Usage:

CalculatorConfigured

Emitted when the calculator is configured or reconfigured.
Parameters:
  • admin (address indexed): Admin who performed the configuration
  • timestamp (uint256): Configuration timestamp
When Emitted:
  • During initial deployment configuration
  • When major configuration changes occur
  • When admin reconfigures the calculator

Event Monitoring

Real-time Score Tracking

Event Analytics

Best Practices

Event Handling

  1. Use Indexed Parameters: Filter events efficiently using indexed parameters
  2. Batch Processing: Process multiple events in batches
  3. Error Handling: Implement robust error handling for event listeners
  4. Performance: Limit block ranges for large queries
  5. Storage: Store important event data in a database

Monitoring Strategy

  1. Real-time Alerts: Set up alerts for significant score changes
  2. Historical Analysis: Regularly analyze historical event data
  3. User Tracking: Track individual user score evolution
  4. System Health: Monitor event emission rates
  5. Anomaly Detection: Detect unusual score patterns