Documentation

This document provides a brief overview of the gotas-raffle smart contract, including explanations for both read and write functions.


github:

https://github.com/arielvdl/gotas/blob/gotas/raffle.sol

Read Functions

1. 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.

2. 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.

3. 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.

4. 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.

5. withdrawalCooldown

  • Description: Shows the waiting period (in seconds) required between withdrawals.

  • Type: public uint

  • Usage: Helps monitor when the next withdrawal can be made.

6. 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.

7. 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.


Write Functions

1. 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.

2. 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.

3. 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.

4. 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.

5. _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.

Last updated