Documentation
Last updated
Last updated
This document provides a brief overview of the gotas-raffle smart contract, including explanations for both read and write functions.
github:
exactAmount
Description: Returns the exact amount required for each deposit.
Type: public uint
Usage: Used to query the fixed amount needed for deposits in the contract.
totalLimit
Description: Returns the total limit that the contract can receive in deposits.
Type: public uint
Usage: Queries the maximum amount that can be deposited into the contract.
totalDeposited
Description: Returns the total amount of funds already deposited into the contract.
Type: public uint
Usage: Shows how much has already been deposited, useful for monitoring the limit.
randomResult
Description: Returns the random number generated by Chainlink VRF.
Type: public uint256
Usage: Used to check the random number generated after calling the requestRandomNumber
function.
withdrawalCooldown
Description: Shows the waiting period (in seconds) required between withdrawals.
Type: public uint
Usage: Helps monitor when the next withdrawal can be made.
unlockDate
Description: Returns the unlock date, after which withdrawals and refunds can be made.
Type: public uint
Usage: Queries whether the unlock date has been reached.
deposits(address)
Description: Returns the amount deposited by a specific address.
Type: public mapping(address => uint)
Usage: Queries how much a specific address has deposited into the contract.
requestRandomNumber
Description: Requests a random number from Chainlink VRF.
Modifier: onlyOwner
Usage: Only the owner can call this function, and it can only be called once to generate a random number. Subsequent calls will be blocked.
Parameter: _maxRange
- Defines the upper limit of the random number.
withdraw
Description: Allows the owner to withdraw funds from the contract after the unlock date has passed.
Modifiers: onlyOwner
, nonReentrant
, afterUnlockDate
Usage: Only the owner can withdraw funds, and the amount cannot exceed the contract's balance.
Parameters:
_to
: The address where the funds will be sent.
_amount
: The amount to withdraw.
receive
Description: A function that allows the contract to receive deposits in ETH.
Usage: Automatically called when someone sends ETH to the contract. Ensures that the value matches the exactAmount
and prevents duplicate deposits from the same address.
fallback
Description: A fallback function that rejects any non-ETH transactions.
Usage: Rejects any other interaction with the contract that is not an ETH deposit.
_registerDeposit
(internal)Description: Registers a deposit made to the contract.
Modifier: internal
Usage: Updates the depositor's balance and adds the depositor to the list if it's their first deposit.