Overview
This document provides a comprehensive reference for all functions available in the ZKScore Protocol 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.
Protocol Management Functions
registerProtocol
Register a new protocol in the registry.
Parameters:
name (string): Protocol name
description (string): Protocol description
protocolType (ProtocolType): Type of protocol (0-7)
dataProvider (address): Authorized data provider address
scoreWeight (uint256): Score contribution weight (basis points)
metadata (bytes): Encoded additional metadata
Returns:
uint256: Newly created protocol ID
Gas Estimate: ~180,000 gas
Requirements:
- Caller must have
REGISTRAR_ROLE
- Name cannot be empty
- Score weight must be reasonable (max 5000 = 50%)
Events Emitted:
ProtocolRegistered(uint256 indexed protocolId, string name, ProtocolType protocolType)
Example Usage:
getProtocol
Get detailed protocol information.
Parameters:
protocolId (uint256): Protocol identifier
Returns:
Protocol: Complete protocol data structure
Gas Estimate: ~5,000 gas (view function)
Example Usage:
isAuthorizedProvider
Check if an address is authorized to provide data for a protocol.
Parameters:
protocolId (uint256): Protocol identifier
provider (address): Provider address to check
Returns:
bool: True if authorized, false otherwise
Gas Estimate: ~2,000 gas (view function)
Error Handling
Common Errors