Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5bA16591C2B46e1395a13Df1a926dA87a2d3887D
Balance 0 ETH
Nonce 1
Code Size 6754 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6754 bytes
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80637caba3ef1161010f578063ac914700116100a2578063d547741f11610071578063d547741f146104d6578063e31ec463146104e9578063e9fe4da71461050c578063f5b541a61461051f57600080fd5b8063ac91470014610421578063bdb917ee1461049d578063cb880d81146104b0578063d536a297146104c357600080fd5b8063939f9cd5116100de578063939f9cd5146103da57806393d3ad8d146103ed578063a217fddf146103f6578063aa880dc4146103fe57600080fd5b80637caba3ef1461037e5780637cb647591461038757806380f732651461039a57806391d14854146103a357600080fd5b806336568abe11610187578063549aa0f211610156578063549aa0f21461032c5780636208faaf14610335578063628d46d01461034857806369d037381461036b57600080fd5b806336568abe146102d05780633c052d1d146102e357806342b2b70c1461030657806344c2d4a31461031957600080fd5b80632eb4a7ab116101c35780632eb4a7ab146102765780632f1042771461027f5780632f2ff15d1461029257806331c2273b146102a557600080fd5b806301ffc9a7146101f55780630613a8981461021d578063248a9ca314610232578063270cce2914610263575b600080fd5b610208610203366004611688565b610546565b60405190151581526020015b60405180910390f35b61023061022b3660046116df565b6105df565b005b6102556102403660046116fc565b60009081526020819052604090206001015490565b604051908152602001610214565b6102306102713660046116fc565b61061a565b61025560035481565b61023061028d366004611761565b61064a565b6102306102a03660046117b4565b6109b4565b6002546102b8906001600160a01b031681565b6040516001600160a01b039091168152602001610214565b6102306102de3660046117b4565b6109d9565b6102086102f13660046116fc565b600d6020526000908152604090205460ff1681565b6102306103143660046116df565b610a2a565b6102306103273660046117fa565b610a65565b61025560055481565b61023061034336600461186b565b610bdb565b6102086103563660046116df565b600f6020526000908152604090205460ff1681565b6102306103793660046116df565b610d2e565b61025560045481565b6102306103953660046116fc565b610d88565b61025560085481565b6102086103b13660046117b4565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6102306103e83660046118b7565b610db8565b61025560015481565b610255600081565b61020861040c3660046116df565b60106020526000908152604090205460ff1681565b61046a61042f3660046116df565b600c60205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff8082169161010090041686565b60408051968752602087019590955293850192909252606084015260ff90811660808401521660a082015260c001610214565b6102306104ab3660046118e0565b61100d565b6007546102b8906001600160a01b031681565b6102306104d13660046116fc565b611075565b6102306104e43660046117b4565b6110a5565b6102086104f73660046116fc565b600e6020526000908152604090205460ff1681565b61023061051a3660046116fc565b6110ca565b6102557f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006105ea816110fa565b506006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610644816110fa565b50600555565b60095460ff161561066e576040516381e05fe560e01b815260040160405180910390fd5b6002546040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810186905233916001600160a01b031690636352211e90602401602060405180830381865afa1580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f491906118fd565b6001600160a01b031614610734576040517f6db2465f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848152600d602052604090205460ff16151560011480156107675750426008546301e133806107659190611930565b115b1561078557604051632cfe303760e21b815260040160405180910390fd5b6000848152600d602052604090205460ff16151560011480156107bb57506000848152600e602052604090205460ff1615156001145b156107d957604051632cfe303760e21b815260040160405180910390fd5b6000848152600e602052604090205460ff161580156108085750426008546301e133806108069190611930565b105b1561087b576000848152600e60205260409020805460ff19166001908117909155600754600654915461084a926001600160a01b039283169216903390611107565b600154604051859033907fcc963d49e5c3571987c1f47092672ee5120e962ea387ef56b3a15613fc64aa0390600090a45b6000848152600d602052604081205460ff16151590036109ae5760025460408051602081018790529081018590526001600160a01b03909116606082015260009060800160405160208183030381529060405280519060200120905061091883838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600354915084905061118f565b6109355760405163582f497d60e11b815260040160405180910390fd5b6000858152600d60205260409020805460ff191660019081179091555461095c9085611930565b60075460065491955061097d916001600160a01b0391821691163387611107565b6040518490869033907f4f05c48fefd874a99acab00ec698d72b07f2d8ae974ad712750d276e6e7c4d3890600090a4505b50505050565b6000828152602081905260409020600101546109cf816110fa565b6109ae83836111a7565b6001600160a01b0381163314610a1b576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a258282611251565b505050565b6000610a35816110fa565b506007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b3360009081526010602052604090205460ff1615610a9657604051636b0a36d560e11b815260040160405180910390fd5b60408051336020820152908101879052606081018690526080810185905260ff841660a082015260009060c001604051602081830303815290604052805190602001209050610b1c83838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600554915084905061118f565b610b395760405163582f497d60e11b815260040160405180910390fd5b336000908152600a602052604090205460ff16158015610b645750600854610b619087611930565b42115b15610bb957600086600854610b799190611930565b90506000610b8a60ff87168a611959565b336000908152601060205260409020805460ff191660011790559050610bb282828b896112d4565b5050610bd2565b604051636b0a36d560e11b815260040160405180910390fd5b50505050505050565b60095460ff1615610bff576040516381e05fe560e01b815260040160405180910390fd5b336000908152600f602052604090205460ff161515600103610c3457604051632cfe303760e21b815260040160405180910390fd5b60408051336020820152908101849052600090606001604051602081830303815290604052805190602001209050610ca383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600454915084905061118f565b610cc05760405163582f497d60e11b815260040160405180910390fd5b336000818152600f60205260409020805460ff19166001179055600754600654610cfb926001600160a01b0392831692919091169087611107565b604051849033907f3e1f30d6a42b6f2b4c7c18a20a71a9d2a39bb053e90ed017b0e49d542ad6c87e90600090a350505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610d58816110fa565b506002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610db2816110fa565b50600355565b336000908152600a602052604090205460ff16610e01576040517fe05eead700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095460ff1615610e25576040516381e05fe560e01b815260040160405180910390fd5b336000908152600c60205260409020600481015460ff61010082048116911603610edb57336000908152600b602052604090205460ff16610ec25760048101546003820154600091610e809161010090910460ff169061196d565b336000818152600b60205260409020805460ff19166001179055600754600654929350610ebc926001600160a01b039182169291169084611107565b50610edb565b60405163a4f8192960e01b815260040160405180910390fd5b600481015460ff6101008204811691610ef5911684611981565b60ff161115610f175760405163a4f8192960e01b815260040160405180910390fd5b600481015462278d0090600090610f3290839060ff1661199a565b90506000610f438360ff871661199a565b905080828560000154610f569190611930565b610f609190611930565b421015610f99576040517fdf065b4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008560ff168560010154610fae919061199a565b6004860180549192508791600090610fca90849060ff16611981565b825460ff9182166101009390930a928302919092021990911617905550600754600654611005916001600160a01b0390811691163384611107565b505050505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929611037816110fa565b6009805460ff19168315159081179091556040517f8e651daebef3ad53721e4f4a510524a5cc45ac64af022a60fb5c307d7edf5d4a90600090a25050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92961109f816110fa565b50600155565b6000828152602081905260409020600101546110c0816110fa565b6109ae8383611251565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296110f4816110fa565b50600455565b61110481336113a0565b50565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526109ae908590611415565b60008261119c8584611491565b1490505b9392505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16611249576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556112013390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016105d9565b5060006105d9565b6000828152602081815260408083206001600160a01b038516845290915281205460ff1615611249576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016105d9565b6040805160c081018252858152602080820186815262278d008385019081526060840187815260006080860181815260ff89811660a0890190815233808552600c89528a852099518a5596516001808b0191909155955160028a015593516003890155905160049097018054935182166101000261ffff19909416979091169690961791909117909455600a909252838320805460ff191690921790915591518492917fe8a7a87237164d57e52cf7119ef197f9234a21869a857975a3b05e1df2022b1791a350505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16611411576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602481018390526044015b60405180910390fd5b5050565b600061142a6001600160a01b038416836114de565b9050805160001415801561144f57508080602001905181019061144d91906119b1565b155b15610a25576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611408565b600081815b84518110156114d6576114c2828683815181106114b5576114b56119ce565b60200260200101516114ec565b9150806114ce816119e4565b915050611496565b509392505050565b60606111a08383600061151b565b60008183106115085760008281526020849052604090206111a0565b60008381526020839052604090206111a0565b606081471015611559576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611408565b600080856001600160a01b0316848660405161157591906119fd565b60006040518083038185875af1925050503d80600081146115b2576040519150601f19603f3d011682016040523d82523d6000602084013e6115b7565b606091505b50915091506115c78683836115d1565b9695505050505050565b6060826115e6576115e182611646565b6111a0565b81511580156115fd57506001600160a01b0384163b155b1561163f576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611408565b50806111a0565b8051156116565780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006020828403121561169a57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146111a057600080fd5b6001600160a01b038116811461110457600080fd5b6000602082840312156116f157600080fd5b81356111a0816116ca565b60006020828403121561170e57600080fd5b5035919050565b60008083601f84011261172757600080fd5b50813567ffffffffffffffff81111561173f57600080fd5b6020830191508360208260051b850101111561175a57600080fd5b9250929050565b6000806000806060858703121561177757600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561179c57600080fd5b6117a887828801611715565b95989497509550505050565b600080604083850312156117c757600080fd5b8235915060208301356117d9816116ca565b809150509250929050565b803560ff811681146117f557600080fd5b919050565b60008060008060008060a0878903121561181357600080fd5b863595506020870135945060408701359350611831606088016117e4565b9250608087013567ffffffffffffffff81111561184d57600080fd5b61185989828a01611715565b979a9699509497509295939492505050565b60008060006040848603121561188057600080fd5b83359250602084013567ffffffffffffffff81111561189e57600080fd5b6118aa86828701611715565b9497909650939450505050565b6000602082840312156118c957600080fd5b6111a0826117e4565b801515811461110457600080fd5b6000602082840312156118f257600080fd5b81356111a0816118d2565b60006020828403121561190f57600080fd5b81516111a0816116ca565b634e487b7160e01b600052601160045260246000fd5b808201808211156105d9576105d961191a565b634e487b7160e01b600052601260045260246000fd5b60008261196857611968611943565b500490565b60008261197c5761197c611943565b500690565b60ff81811683821601908111156105d9576105d961191a565b80820281158282048414176105d9576105d961191a565b6000602082840312156119c357600080fd5b81516111a0816118d2565b634e487b7160e01b600052603260045260246000fd5b6000600182016119f6576119f661191a565b5060010190565b6000825160005b81811015611a1e5760208186018101518583015201611a04565b50600092019182525091905056fea264697066735822122071a7e3f67329756230a9313de65caecba1a8556308dbc282ee0ccbefaf9d776164736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: paris Optimization: Yes (1000 runs)
NFTClaimable.sol 472 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

interface IERC721 {
    function ownerOf(uint256 tokenId) external view returns (address owner);
}

/// @title NFTClaimable: SafeERC20 compatible claims and vesting contract for Karrats.

contract NFTClaimable is AccessControl {
    using SafeERC20 for IERC20;

    // Role for operator
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

    // Storage for amount of tokens per NFT
    uint256 public amountOfTokensPerNFT;

    // Storage for NFTContract
    address public NFTContract;

    // Merkle Root for NFTs
    bytes32 public merkleRoot;

    // Merkle Root for Earnings
    bytes32 public merkleRootForEarnings;

    // Merkle Root For Vesting
    bytes32 public merkleRootForVesting;

    // Storage for the Release Wallet
    address private releaseWallet;

    // Storage for the Karrat Token
    address public karratToken;

    // Storage for Deploy TimeStamp
    uint public deployTimeStamp;

    // Claims paused
    bool private claimsPaused;

    // Address is Presale Buyer
    mapping(address => bool) private approvedAddress;

    // Address is Presale Buyer
    mapping(address => bool) private remainderGiven;

    // beneficiary => recurring vesting schedules
    mapping(address => RecurringVesting) public recurringVestingSchedules;

    // token => vesting schedules
    mapping(uint256 => bool) public hasTheNFTClaimedTheKarratToken;

    // NFT - allowed Karrats to be claimed after 365 days
    mapping(uint256 => bool) public hasTheNFTClaimedTheSecondSetOfKarratTokens;

    // Address has claimed earned tokens
    mapping(address => bool) public hasClaimedEarnedTokens;

    // Address has claimed vested tokens
    mapping(address => bool) public vestingClaimed;

    // multiple vesting schedules per beneficiary
    struct RecurringVesting {
        uint256 startTimestamp;
        uint256 amountPerWithdrawal;
        uint256 withdrawalInterval;
        uint256 totalTokens;
        uint8 numberOfWithdrawalsExecuted;
        uint8 numberOfTotalWithdrawals;
    }

    // Errors
    error CallerIsNotOwner();
    error RewardAlreadyClaimed();
    error TokensStillLocked();
    error TokensAlreadyClaimed();
    error NotTimeYetOrDuplicateClaim();
    error NotApprovedAddress();
    error InvalidMerkleProof();
    error ClaimsArePaused();

    // Events
    event NFTHasClaimed(
        address indexed holder,
        uint256 indexed tokenId,
        uint256 indexed amount
    );
    event NFTHasClaimedFinalAmount(
        address indexed holder,
        uint256 indexed tokenId,
        uint256 indexed amount
    );
    event AddressClaimedEarnedTokens(
        address indexed earner,
        uint256 indexed amount
    );
    event TokensSetToVest(
        address indexed beneficiary,
        uint256 indexed totalTokensVesting
    );
    event ClaimStatusAdjusted(
        bool indexed status
    );

    modifier isApprovedAddress() {
        if (!approvedAddress[msg.sender]) {
            revert NotApprovedAddress();
        }

        _;
    }

    modifier claimHasBeenSet() {
        if (vestingClaimed[msg.sender]) {
            revert NotTimeYetOrDuplicateClaim();
        }
        _;
    }

     modifier claimsArePaused() {
        if (claimsPaused) {
            revert ClaimsArePaused();
        }
        _;
    }

    constructor(
        address _karratToken,
        address _NFTContract,
        address ReleaseWallet,
        bytes32 _merkleRoot,
        bytes32 _merkleRootForEarnings,
        bytes32 _merkleRootForVesting,
        address operator
    ) {
        deployTimeStamp = block.timestamp;
        karratToken = _karratToken;
        releaseWallet = ReleaseWallet;
        merkleRoot = _merkleRoot;
        merkleRootForEarnings = _merkleRootForEarnings;
        merkleRootForVesting = _merkleRootForVesting;
        NFTContract = _NFTContract;
        amountOfTokensPerNFT = 1125 * 1e18;
        _grantRole(DEFAULT_ADMIN_ROLE, ReleaseWallet);
        _grantRole(OPERATOR_ROLE, operator);
    }

    /**
     * @notice Claims tokens for an NFT holder based on a Merkle proof.
     * @dev Verifies the ownership and claim status of the NFT, then mints tokens to the caller.
     * @param tokenId The ID of the NFT.
     * @param amount The amount of tokens to claim.
     * @param merkleProof A Merkle proof proving the claim is valid.
     */
    function claimNFTRelatedTokens(
        uint256 tokenId,
        uint256 amount,
        bytes32[] calldata merkleProof
    ) external 
    claimsArePaused
    {
        if (IERC721(NFTContract).ownerOf(tokenId) != msg.sender) {
            revert CallerIsNotOwner();
        }
        if (
            hasTheNFTClaimedTheKarratToken[tokenId] == true &&
            deployTimeStamp + 365 days > block.timestamp
        ) {
            revert RewardAlreadyClaimed();
        }
        if (
            hasTheNFTClaimedTheKarratToken[tokenId] == true &&
            hasTheNFTClaimedTheSecondSetOfKarratTokens[tokenId] == true
        ) {
            revert RewardAlreadyClaimed();
        }
        if (
            hasTheNFTClaimedTheSecondSetOfKarratTokens[tokenId] == false &&
            deployTimeStamp + 365 days < block.timestamp
        ) {
            hasTheNFTClaimedTheSecondSetOfKarratTokens[tokenId] = true;
            SafeERC20.safeTransferFrom(
                IERC20(karratToken),
                releaseWallet,
                msg.sender,
                amountOfTokensPerNFT
            );
            emit NFTHasClaimedFinalAmount(
                msg.sender,
                tokenId,
                amountOfTokensPerNFT
            );
        }
        if (hasTheNFTClaimedTheKarratToken[tokenId] == false) {
            // Verify the Merkle proof
            bytes32 leaf = keccak256(abi.encode(tokenId, amount, NFTContract));
            if (!MerkleProof.verify(merkleProof, merkleRoot, leaf)) {
                revert InvalidMerkleProof();
            }

            // Mark as claimed and transfer the ERC-20 tokens
            hasTheNFTClaimedTheKarratToken[tokenId] = true;
            amount += amountOfTokensPerNFT;
            SafeERC20.safeTransferFrom(
                IERC20(karratToken),
                releaseWallet,
                msg.sender,
                amount
            );

            emit NFTHasClaimed(msg.sender, tokenId, amount);
        }
    }

    /**
     * @notice Claims tokens based on an address and amount with a Merkle proof verification.
     * @dev Verifies the claim hasn't been made yet and the proof is valid before minting tokens to the caller.
     * @param amount The amount of tokens to claim.
     * @param merkleProof A Merkle proof that validates the claim.
     */
    function claimForAddress(
        uint256 amount,
        bytes32[] calldata merkleProof
    ) external
    claimsArePaused {
        if (hasClaimedEarnedTokens[msg.sender] == true) {
            revert RewardAlreadyClaimed();
        }

        bytes32 leaf = keccak256(abi.encode(msg.sender, amount));
        if (!MerkleProof.verify(merkleProof, merkleRootForEarnings, leaf)) {
            revert InvalidMerkleProof();
        }

        hasClaimedEarnedTokens[msg.sender] = true;
        SafeERC20.safeTransferFrom(
            IERC20(karratToken),
            releaseWallet,
            msg.sender,
            amount
        );
        emit AddressClaimedEarnedTokens(msg.sender, amount);
    }

    /**
     * @notice Claims tokens based on a vesting schedule with a Merkle proof verification.
     * @dev Verifies the claim hasn't been made yet and the proof is valid before minting tokens to the caller.
     * @param amountOfTotalTokens The total amount of tokens to claim.
     * @param holdPeriod The time to hold the tokens before claiming.
     * @param deliveryPeriod The time to deliver the tokens after the hold period.
     * @param totalMonths The total number of months for the vesting schedule.
     * @param merkleProof A Merkle proof that validates the claim.
     */
    function claimVestingSchedule(
        uint amountOfTotalTokens,
        uint holdPeriod,
        uint deliveryPeriod,
        uint8 totalMonths,
        bytes32[] calldata merkleProof
    ) external claimHasBeenSet {
        bytes32 leaf = keccak256(
            abi.encode(
                msg.sender,
                amountOfTotalTokens,
                holdPeriod,
                deliveryPeriod,
                totalMonths
            )
        );
        if (!MerkleProof.verify(merkleProof, merkleRootForVesting, leaf)) {
            revert InvalidMerkleProof();
        }

        if (
            !approvedAddress[msg.sender] &&
            block.timestamp > holdPeriod + deployTimeStamp
        ) {
            uint startTime = deployTimeStamp + holdPeriod;
            uint tokensPerWithdraw = amountOfTotalTokens / totalMonths;
            vestingClaimed[msg.sender] = true;
            _setUpVesting(
                startTime,
                tokensPerWithdraw,
                amountOfTotalTokens,
                totalMonths
            );
        } else {
            revert NotTimeYetOrDuplicateClaim();
        }
    }

    /**
     * @notice Claims vested tokens based on a vesting schedule.
     * @dev Verifies the claim hasn't been made yet and the proof is valid before minting tokens to the caller.
     * @param claimsPending The number of claims to make.
     */

    function claimVestedTokens(uint8 claimsPending) external isApprovedAddress claimsArePaused {
        RecurringVesting storage vesting = recurringVestingSchedules[
            msg.sender
        ];

        if (
            vesting.numberOfWithdrawalsExecuted ==
            vesting.numberOfTotalWithdrawals
        ) {
            if (!remainderGiven[msg.sender]) {
                uint remainder = vesting.totalTokens %
                    vesting.numberOfTotalWithdrawals;
                remainderGiven[msg.sender] = true;
                SafeERC20.safeTransferFrom(
                    IERC20(karratToken),
                    releaseWallet,
                    msg.sender,
                    remainder
                );
            } else {
                revert TokensAlreadyClaimed();
            }
        }
        if(claimsPending + vesting.numberOfWithdrawalsExecuted > vesting.numberOfTotalWithdrawals){
            revert TokensAlreadyClaimed();
        }

        uint month = 30 days;

        uint months = vesting.numberOfWithdrawalsExecuted * month; // 0

        uint monthsBeingClaimed = claimsPending * month; // 1 month

        if (
            block.timestamp <
            vesting.startTimestamp + months + monthsBeingClaimed
        ) {
            revert TokensStillLocked();
        }
        uint256 amount = vesting.amountPerWithdrawal * claimsPending;

        vesting.numberOfWithdrawalsExecuted += claimsPending;

        SafeERC20.safeTransferFrom(
            IERC20(karratToken),
            releaseWallet,
            msg.sender,
            amount
        );
    }

    /**
     * @notice Pauses claims.
     * @dev Only callable by accounts with the OPERATOR.
     */

    function setPauseStatusOfClaims(bool status) external onlyRole(OPERATOR_ROLE) {
        claimsPaused = status;
        emit ClaimStatusAdjusted(status);
    }

    /**
     * @notice Sets the Karrat Token address.
     * @dev Only callable by accounts with the DEFAULT_ADMIN_ROLE.
     * @param _karratToken The new Karrat Token address.
     */

    function setKarratToken(
        address _karratToken
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        karratToken = _karratToken;
    }

    /**
     * @notice Sets the Karrat Release Wallet address.
     * @dev Only callable by accounts with the DEFAULT_ADMIN_ROLE.
     * @param _releaseWallet The new Release Wallet address.
     */

    function setReleaseWallet(
        address _releaseWallet
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        releaseWallet = _releaseWallet;
    }

    /**
     * @notice Sets the Merkle root for NFT-based token claims.
     * @dev Only callable by accounts with the OPERATOR_ROLE.
     * @param _merkleRoot The new Merkle root.
     */
    function setMerkleRoot(
        bytes32 _merkleRoot
    ) external onlyRole(OPERATOR_ROLE) {
        merkleRoot = _merkleRoot;
    }

    /**
     * @notice Sets the Merkle root for address-based token claims.
     * @dev Assumes the same role-based access control for consistency.
     * @param _merkleRootForEarnings The new Merkle root for address-based claims.
     */
    function setMerkleRootForEarnings(
        bytes32 _merkleRootForEarnings
    ) external onlyRole(OPERATOR_ROLE) {
        merkleRootForEarnings = _merkleRootForEarnings;
    }

    /**
     * @notice Sets the Merkle root for vesting-based token claims.
     * @dev Assumes the same role-based access control for consistency.
     * @param _merkleRootForVesting The new Merkle root for vesting-based claims.
     */
    function setMerkleRootForVesting(
        bytes32 _merkleRootForVesting
    ) external onlyRole(OPERATOR_ROLE) {
        merkleRootForVesting = _merkleRootForVesting;
    }

    /**
     * @notice Sets the NFT contract address.
     * @dev Only callable by accounts with the OPERATOR_ROLE.
     * @param _NFTContract The new NFT contract address.
     */
    function setNFTAddress(
        address _NFTContract
    ) external onlyRole(OPERATOR_ROLE) {
        NFTContract = _NFTContract;
    }

    /**
     * @notice Sets the amount of tokens per NFT.
     * @dev Only callable by accounts with the OPERATOR_ROLE.
     * @param _amountOfTokensPerNFT The new amount of tokens per NFT.
     */
    function setTokensPerNFT(
        uint _amountOfTokensPerNFT
    ) external onlyRole(OPERATOR_ROLE) {
        amountOfTokensPerNFT = _amountOfTokensPerNFT;
    }

    /**
     * @notice Sets the approved address for claiming tokens.
     * @dev Only callable internally after caller if verified above.
     * @param startTimestamp The start time for the vesting schedule to be claimed
     * @param amountPerWithdrawal The amount of tokens to be claimed per withdrawal.
     * @param totalTokens The total amount of tokens to be claimed.
     * @param numberOfWithdrawals The number of withdrawals to be made.
     */
    function _setUpVesting(
        uint256 startTimestamp,
        uint256 amountPerWithdrawal,
        uint256 totalTokens,
        uint8 numberOfWithdrawals
    ) internal {
        recurringVestingSchedules[msg.sender] = (
            RecurringVesting(
                startTimestamp,
                amountPerWithdrawal,
                30 days,
                totalTokens,
                0,
                numberOfWithdrawals
            )
        );
        approvedAddress[msg.sender] = true;
        emit TokensSetToVest(msg.sender, totalTokens);
    }
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
AccessControl.sol 209 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
MerkleProof.sol 232 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.20;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Sorts the pair (a, b) and hashes the result.
     */
    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
NFTContract 0x31c2273b → address
OPERATOR_ROLE 0xf5b541a6 → bytes32
amountOfTokensPerNFT 0x93d3ad8d → uint256
deployTimeStamp 0x80f73265 → uint256
getRoleAdmin 0x248a9ca3 → bytes32
hasClaimedEarnedTokens 0x628d46d0 → bool
hasRole 0x91d14854 → bool
hasTheNFTClaimedTheKarratToken 0x3c052d1d → bool
hasTheNFTClaimedTheSecondSetOfKarratTokens 0xe31ec463 → bool
karratToken 0xcb880d81 → address
merkleRoot 0x2eb4a7ab → bytes32
merkleRootForEarnings 0x7caba3ef → bytes32
merkleRootForVesting 0x549aa0f2 → bytes32
recurringVestingSchedules 0xac914700 → uint256, uint256, uint256, uint256, uint8, uint8
supportsInterface 0x01ffc9a7 → bool
vestingClaimed 0xaa880dc4 → bool

Write Contract 15 functions

These functions modify contract state and require a wallet transaction to execute.

claimForAddress 0x6208faaf
uint256 amount
bytes32[] merkleProof
claimNFTRelatedTokens 0x2f104277
uint256 tokenId
uint256 amount
bytes32[] merkleProof
claimVestedTokens 0x939f9cd5
uint8 claimsPending
claimVestingSchedule 0x44c2d4a3
uint256 amountOfTotalTokens
uint256 holdPeriod
uint256 deliveryPeriod
uint8 totalMonths
bytes32[] merkleProof
grantRole 0x2f2ff15d
bytes32 role
address account
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
setKarratToken 0x42b2b70c
address _karratToken
setMerkleRoot 0x7cb64759
bytes32 _merkleRoot
setMerkleRootForEarnings 0xe9fe4da7
bytes32 _merkleRootForEarnings
setMerkleRootForVesting 0x270cce29
bytes32 _merkleRootForVesting
setNFTAddress 0x69d03738
address _NFTContract
setPauseStatusOfClaims 0xbdb917ee
bool status
setReleaseWallet 0x0613a898
address _releaseWallet
setTokensPerNFT 0xd536a297
uint256 _amountOfTokensPerNFT

Recent Transactions

No transactions found for this address