Documentation for the Consumption Smart Contract
The following documentation is for reference purposes only. Our platform has built in services for deploying your model and making it available for consumption, hence calling these functions directly is not necessary.
Contract Initialization
initialize(IERC20 _paymentToken, address _admin, address _creator, address _competitionContract, uint16 _modelerShare, uint16 _validatorShare, uint16 _adminShare, uint16 _creatorShare)
initialize(IERC20 _paymentToken, address _admin, address _creator, address _competitionContract, uint16 _modelerShare, uint16 _validatorShare, uint16 _adminShare, uint16 _creatorShare)
This function initializes the smart contract with initial tokens, user roles and reward parameters and. It is executed only once upon deployment and cannot be called again due to the initializer
modifier.
_paymentToken
: Address of the ERC20 token used for payment within the platform._admin
: Address of the contract admin._creator
: Address of the contract creator._competitionContract
: Address of the Competition contract that orchestrates the overall workflow._modelerShare
,_validatorShare
,_adminShare
,_creatorShare
: Percentage shares (out of 10,000) for distributing rewards among modelers, validators, the admin, and the creator, respectively.
Making and Responding to Requests
makeConsumerRequest(string calldata _input)
makeConsumerRequest(string calldata _input)
Allows a consumer to submit a data inference request. Requires the consumption window to be active and the consumer to have a sufficient payment balance.
_input
: The data for which an inference is requested.
submitInference(bytes32 _requestId, uint256 _inference)
submitInference(bytes32 _requestId, uint256 _inference)
Enables a modeler to submit an inference response to a specific request.
_requestId
: The unique identifier of the consumer's request._inference
: The modeler's inference data.
Reward Distribution
claimReward(uint256 rewardEpoch)
claimReward(uint256 rewardEpoch)
Allows users (modelers, validators, admin, and creator) to claim their earned rewards for a specific reward epoch.
rewardEpoch
: The epoch for which rewards are being claimed.
Administrative Functions
toggleConsumptionWindow(bool toggle)
toggleConsumptionWindow(bool toggle)
Used by the contract admin to open or close the consumption window, thereby enabling or disabling the submission of new inference requests.
toggle
: Boolean value to open (true
) or close (false
) the consumption window.
setRewardEpoch(uint256 _newEpochDuration)
setRewardEpoch(uint256 _newEpochDuration)
Allows the admin to adjust the duration of reward epochs.
_newEpochDuration
: The new duration (in seconds) of reward epochs.
setBountyPayoutPeriod(uint256 _newBountyPayoutPeriod)
setBountyPayoutPeriod(uint256 _newBountyPayoutPeriod)
Enables the admin to change the period after which bounty payouts are distributed.
_newBountyPayoutPeriod
: The new bounty payout period (in seconds).
Utility Functions
calculateEpoch()
calculateEpoch()
Calculates the current reward epoch based on the epoch start time and duration.
generateRequestID(string calldata _input, uint256 _blockTimestamp, address _sender)
generateRequestID(string calldata _input, uint256 _blockTimestamp, address _sender)
Generates a unique request ID for each inference request.
_input
: The input data of the request._blockTimestamp
: The timestamp of the block in which the request is made._sender
: The address of the requestor.
Events
InferenceSubmitted
: Emitted when a modeler submits an inference.InferenceProofRequested
: Emitted when a validator requests proof of inference from a modeler.InferenceProofSubmitted
: Emitted when a modeler submits proof of their inference.RewardsAllocated
: Indicates the allocation of rewards for a request.RewardClaimed
: Emitted when a user claims their reward for a specific epoch.ConsumptionWindowToggled
: Indicates the opening or closing of the consumption window.RewardEpochChanged
: Emitted when the reward epoch duration is updated.BountyPayoutPeriodChanged
: Emitted when the bounty payout period is adjusted.
Last updated