Reward Metadata
The Rewards Metadata feature allows applications to enrich reward distributions with additional contextual information. This is facilitated through the distributeRewardWithProofAndMetadata
function, which accepts a JSON-formatted string as metadata.
The provided metadata is then emitted via the RewardMetadata
event, enabling off-chain services to efficiently index, analyze, and utilize the data for tracking and reporting purposes.
Suggested Metadata Structure
To maintain consistency across applications, it's recommended to follow a standardized metadata structure. Below is an example of a JSON-formatted metadata string:
Keep in mind that including location metadata may require updating your privacy policy and terms of service.
Examples
To provide metadata you need to distribute the rewards through the X2EarnRewardsPool contract with the following function:
Emitted Event: RewardMetadata
RewardMetadata
Upon successful execution of the distributeRewardWithProofAndMetadata
function, the RewardMetadata
event is emitted with the following parameters:
amount (
uint256
): The distributed reward amount.appId (
bytes32
): The application identifier.receiver (
address
): The address receiving the reward.metadata (
string
): The JSON-formatted metadata string.distributor (
address
): The address initiating the distribution.
This event allows off-chain systems to listen for and process reward distributions along with their associated metadata.
Guidelines
Optional Usage: The
metadata
is optional. If your application doesn't require additional context, you can continue using the existingdistributeRewardWithProof
function.Standardization: Adhere to the suggested metadata structure to ensure consistency and facilitate seamless data integration across the ecosystem.
Data Validation: Implement validation checks to ensure the metadata JSON is correctly formatted and contains relevant information before invoking the distribution function.
Last updated
Was this helpful?