PrizeDistributor
The PrizeDistributor contract holds Tickets (captured interest) and distributes tickets to users with winning draw claims. A manager account can indicate the winners that will receive the payment of the prizes.
Write methods description
cancelRandomnessRequest()
Allow anyone to cancel a randomness request if the RNG service timed out.
initialize()
Allows to initialize the contract during the deployment. Initialize PrizeDistributor smart contract.
Parameters:
_owner
address
Owner address.
_token
address
Token address.
_drawBuffer
address
DrawBuffer address.
_prizeDistributionBuffer
address
PrizeDistributionBuffer address.
_rngService
address
RNG service address.
_distribution
uint16[]
Initial array with distribution percentages.
_rngTimeout
uint32
RNG request timeout in seconds.
payWinners()
Pay prizes to winners using current prizes distribution. Only callable by contract manager.
Parameters:
_drawId
uint32
An ID of a draw to pay prizes for.
_winners
address[]
Winners of a draw.
Return:
_success
bool
true
if operation is successful.
processRandomness()
Retrieves an array of random numbers that was requested for a draw and processes it. Only callable by contract manager.
Parameters:
_drawId
uint32
An ID of a draw to retrieve random numbers for.
Return:
_randomness
uint256[]
An array of random numbers for a draw.
requestRandomness()
Requests an array of random numbers for a draw according to the current prizes distribution length. Only callable by contract manager.
Parameters:
_drawId
uint32
An ID of a draw to request random numbers for.
_picksNumber
uint256
A number of picks (participants) in a draw.
_participantsHash
bytes
An IPFS hash that links to a list of participants in a draw.
_isEmptyDraw
bool
A flag that indicates if a draw has no participants.
setDistribution()
Set prizes distribution.
Parameters:
_distribution
uint16[]
Prizes distribution to set up.
setDrawBuffer()
Set a DrawBuffer.
Parameters:
_drawBuffer
address
A new DrawBuffer to set up.
setPrizeDistributionBuffer()
Set a PrizeDistributionBuffer.
Parameters:
_prizeDistributionBuffer
address
A new PrizeDistributionBuffer to set up.
withdrawERC20()
Transfer ERC20 tokens out of contract to recipient address. Only callable by contract owner.
Parameters:
_token
address
IERC20Upgradeable token to transfer.
_to
address
Recipient of the tokens.
_amount
uint256
Amount of tokens to transfer.
Return:
_success
bool
true
if operation is successful.
claimOwnership()
Allows the pendingOwner
address to claim the owner role. This function is only callable by the pendingOwner
.
renounceOwnership()
Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
transferOwnership()
Transfers ownership of the contract to a _pendingOwner
. Can only be called by the current owner.
Parameters:
_newOwner
address
an account that will become the _pendingOwner
.
setManager()
Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManager
or onlyManagerOrOwner
.
Parameters:
_newManager
address
An account that will become the new manager.
setRngService()
Allows to set a RNG service that the PrizeDistributor is connected to. Can only be called by the current owner.
Parameters:
_rngService
IRNGServiceChainlinkV2
The address of the new RNG service interface.
setRngTimeout()
Allows to set an RNG request timeout in seconds. This is the time that must elapse before an RNG request can be canceled. Can only be called by the current owner.
Parameters:
_rngTimeout
uint32
An RNG request timeout in seconds.
Read methods description
ONE_HUNDRED_PERCENTS()
100% with 2 decimal points (i.s. 10000 == 100.00%).
getDistribution()
Read global prizes distribution. Returns an array with the split percentages in which the prizes will be distributed.
getDrawBuffer()
Read global DrawBuffer address. The DrawBuffer contains information about the draw.
getLastRngRequest()
Read global info about the last RNG request (ID, lock block and timestamp).
getLastUnpaidDrawId()
Read global last unpaid draw ID. It increments when the draw is paid.
getNumberOfWinners()
Read global prizes distribution length.
getPrizeDistributionBuffer()
Read global PrizeDistributionBuffer address.
getRngService()
Read global RNGServiceChainlinkV2 address.
getRngTimeout()
Read global RNG timeout. Timeout is presented in seconds.
getToken()
Read global Ticket address.
isRngCompleted()
Returns whether a random numbers request has been completed.
isRngRequested()
Returns whether a random numbers has been requested.
isRngTimedOut()
Returns whether a random numbers request has been timed out.
owner()
Owner role that can be granted exclusive access to specific functions with the modifier onlyOwner
.
manager()
Manager role that can be granted exclusive access to specific functions with the modifier onlyManager
or onlyManagerOrOwner
.
pendingOwner()
Address that can claim the owner role. It is used to transfer the owner.
Last updated