Cuentas
0xb6...c2a4
0xb6...c2A4

0xb6...c2A4

$500
¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.8.28+commit.7893614a
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 1: Earn3DailyCheckIn.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

contract Earn3DailyCheckIn {
    address public owner;
    mapping(address => uint256[]) public checkInDates;
    address[] private users;

    event CheckedIn(address indexed user, uint256 timestamp);

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can access this function");
        _;
    }

    constructor() {
        owner = msg.sender;
    }

    receive() external payable {
        revert("Fund transfers are not allowed to this contract");
    }

    fallback() external payable {
        revert("Fund transfers are not allowed to this contract");
    }

    function checkIn() public {
        uint256 currentTimestamp = block.timestamp;
        uint256[] storage userCheckIns = checkInDates[msg.sender];

        if (userCheckIns.length > 0 && (currentTimestamp / 1 days) == (userCheckIns[userCheckIns.length - 1] / 1 days)) {
            revert("AlreadyCheckedInToday");
        }

        if (userCheckIns.length == 0) {
            users.push(msg.sender);
        }

        userCheckIns.push(currentTimestamp);
        emit CheckedIn(msg.sender, currentTimestamp);
    }

    function getCheckInDates(address user) public view returns (uint256[] memory) {
        return checkInDates[user];
    }

    function hasCheckedInToday(address user) public view returns (bool) {
        uint256[] storage userCheckIns = checkInDates[user];
        if (userCheckIns.length == 0) {
            return false;
        }
        uint256 today = block.timestamp / 1 days;
        uint256 lastCheckInDate = userCheckIns[userCheckIns.length - 1] / 1 days;
        return today == lastCheckInDate;
    }

    function getAllCheckIns() public view onlyOwner returns (address[] memory, uint256[][] memory) {
        uint256[][] memory allCheckIns = new uint256[][](users.length);
        
        for (uint256 i = 0; i < users.length; i++) {
            allCheckIns[i] = checkInDates[users[i]];
        }

        return (users, allCheckIns);
    }
}
Configuraciones
{
  "compilationTarget": {
    "contracts/Earn3DailyCheckIn.sol": "Earn3DailyCheckIn"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CheckedIn","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"checkIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"checkInDates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllCheckIns","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[][]","name":"","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getCheckInDates","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"hasCheckedInToday","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]