Address Contract Verified
Address
0xEDAFA8B3f4bb3671e0cf923517FD9a2CDE710298
Balance
0 ETH
Nonce
1
Code Size
2971 bytes
Creator
0xE1925D7a...0b98 at tx 0x1752067f...248bd7
Indexed Transactions
0
Contract Bytecode
2971 bytes
0x6080604052600436101561001257600080fd5b60003560e01c80630379fefa1461082e578063037d2643146106f75780630de959cc146106ce578063171c41af1461065457806326a4e8d2146105b25780634e71d92d146104175780635c975abb146103f4578063715018a61461039157806379ba5097146102fa5780638da5cb5b146102cd5780639d76ea58146102a4578063a249225e146101e0578063bedb86fb14610162578063d5b9221b146101235763f2fde38b146100c157600080fd5b3461011e57602036600319011261011e576100da61093e565b6100f260018060a01b0360005460081c163314610954565b6001600160a01b0316801561011e576bffffffffffffffffffffffff60a01b6001541617600155600080f35b600080fd5b3461011e57602036600319011261011e576001600160a01b0361014461093e565b166000526002602052602060ff604060002054166040519015158152f35b3461011e57602036600319011261011e5760043580151580910361011e576000549060ff9061019f33600885901c6001600160a01b031614610954565b1680809260ff1916176000556101b157005b60207f140eb9f8b591138e129e4caf389c92df4f0545b902523eee9e63153ecdb2026e916040519015158152a1005b3461011e57604036600319011261011e576101f961093e565b602435908115159182810361011e577f1d778915579d1eab571aaabfef4cad45f44457b46165d03669a495599a5f5a6d9160209161024560018060a01b0360005460081c163314610954565b15610280576001600160a01b03811660009081526002835260409020805460ff191660011790555b6040519384526001600160a01b031692a2005b6001600160a01b03811660009081526002835260409020805460ff1916905561026d565b3461011e57600036600319011261011e576004546040516001600160a01b039091168152602090f35b3461011e57600036600319011261011e5760005460405160089190911c6001600160a01b03168152602090f35b3461011e57600036600319011261011e5760005461031b60ff8216156109f7565b600154906001600160a01b0382163381900361011e57600882901c6001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3610100600160a81b031916600882901b610100600160a81b0316176000556001600160a01b031916600155005b3461011e57600036600319011261011e576000805490600882901c6001600160a01b03166103c0338214610954565b7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3610100600160a81b031916600055005b3461011e57600036600319011261011e57602060ff600054166040519015158152f35b3461011e57600036600319011261011e5761043760ff60005416156109f7565b6002600354146105a157600260035561044f33610a58565b8015610566573360005260056020526004604060002001805490828201809211610550575560018060a01b03600454166040516020810163a9059cbb60e01b815233602483015283604483015260448252608082019082821067ffffffffffffffff83111761053a57602092600092604052519082855af11561052e576000513d6105255750803b155b61051157506040519081527f896e034966eaaf1adc54acc0f257056febbd300c9e47182cf761982cf1f5e43060203392a26001600355005b635274afe760e01b60005260045260246000fd5b600114156104d9565b6040513d6000823e3d90fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b8152602060048201526013602482015272139bc818db185a5b58589b1948185b5bdd5b9d606a1b6044820152606490fd5b633ee5aeb560e01b60005260046000fd5b3461011e57602036600319011261011e576105cb61093e565b6105e360018060a01b0360005460081c163314610954565b6001600160a01b0316801561060f576bffffffffffffffffffffffff60a01b6004541617600455600080f35b60405162461bcd60e51b815260206004820152601860248201527f5a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006044820152606490fd5b3461011e57602036600319011261011e576001600160a01b0361067561093e565b166000526005602052604060002080546106ca6001830154926002810154906004600382015491015491604051958695869192608093969594919660a084019784526020840152604083015260608201520152565b0390f35b3461011e57600036600319011261011e576001546040516001600160a01b039091168152602090f35b3461011e5760a036600319011261011e5761071061093e565b602435604435606435916084359361073660018060a01b0360005460081c163314610954565b6001600160a01b03166000818152600560205260409020549094906107e9577f7d115f4f4671ada8dfbb29614639dbf064568cf444c1d48f4b6d27b0b0feddee93608093604051610786816109db565b84815260046020820185815260408301848152606084019086825289850192600084528c600052600560205260406000209551865551600186015551600285015551600384015551910155604051938452602084015260408301526060820152a2005b60405162461bcd60e51b815260206004820152601760248201527f436c61696d616e7420616c7265616479206578697374730000000000000000006044820152606490fd5b3461011e5760c036600319011261011e5761084761093e565b7f13edfb49cac1c29666e93981d783410ca79a5e198a368c36df17624b90aab772602435604435906109396064359460843560a4359161089560018060a01b0360005460081c163314610954565b60018060a01b0316968760005260056020526108b76040600020541515610999565b6040516108c3816109db565b85815260046020820184815260408301898152606084019085825260808501928884528d600052600560205260406000209551865551600186015551600285015551600384015551910155604051958695869192608093969594919660a084019784526020840152604083015260608201520152565b0390a2005b600435906001600160a01b038216820361011e57565b1561095b57565b60405162461bcd60e51b815260206004820152601660248201527531b0b63632b91034b9903737ba1030b71037bbb732b960511b6044820152606490fd5b156109a057565b60405162461bcd60e51b8152602060048201526013602482015272436c61696d616e74206e6f7420666f756e642160681b6044820152606490fd5b60a0810190811067ffffffffffffffff82111761053a57604052565b156109fe57565b60405162461bcd60e51b815260206004820152601260248201527118dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606490fd5b8181029291811591840414171561055057565b9190820391821161055057565b6001600160a01b03166000908152600560205260409020805490610a7d821515610999565b600181015491824210610b2057600382015491610a9a8383610a38565b93600482015494851015610b1657610ab460029142610a4b565b910154908115610b005704600101918260011161055057610add9281811115610af95750610a38565b9080821115610af257610aef91610a4b565b90565b5050600090565b9050610a38565b634e487b7160e01b600052601260045260246000fd5b5050505050600090565b60405162461bcd60e51b815260206004820152601f60248201527f436c61696d696e6720706572696f6420686173206e6f742073746172746564006044820152606490fdfea2646970667358221220ab2f902f017aa65f33ab67332d10be3763e5ec491762eb170d02f0dd2f676ea264736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: paris
Optimization: Yes (200 runs)
LinearClaim.sol 137 lines
//SPDX-License-Identifier: GPL 3
pragma solidity >=0.8.19 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "src/utils/TokenAccessControl.sol";
contract LinearClaim is TokenAccessControl, ReentrancyGuard {
using SafeERC20 for IERC20;
address public tokenAddress;
struct Claimant {
uint256 claim;
uint256 firstClaimAt;
uint256 claimCooldown;
uint256 claimCount;
uint256 claimed;
}
mapping(address => Claimant) public claimants;
event ClaimantAdded(
address indexed claimant,
uint256 claim,
uint256 claimCooldown,
uint256 claimCount,
uint256 firstClaimAt
);
event ClaimantUpdated(
address indexed claimant,
uint256 claim,
uint256 claimCooldown,
uint256 claimCount,
uint256 firstClaimAt,
uint256 claimed
);
event TokensClaimed(address indexed claimant, uint256 amount);
constructor(address _tokenAddress) {
require(_tokenAddress != address(0), "Zero address not allowed");
tokenAddress = _tokenAddress;
}
function setTokenAddress(address _tokenAddress) public onlyOwner {
require(_tokenAddress != address(0), "Zero address not allowed");
tokenAddress = _tokenAddress;
}
function addClaimant(
address _claimant,
uint256 _claim,
uint256 _claimCooldown,
uint256 _claimCount,
uint256 _firstClaimAt
) public onlyOwner {
require(claimants[_claimant].claim == 0, "Claimant already exists");
claimants[_claimant] = Claimant(
_claim,
_firstClaimAt,
_claimCooldown,
_claimCount,
0
);
emit ClaimantAdded(
_claimant,
_claim,
_claimCooldown,
_claimCount,
_firstClaimAt
);
}
function setClaimantClaim(
address _claimant,
uint256 _claim,
uint256 _claimCooldown,
uint256 _claimCount,
uint256 _firstClaimAt,
uint256 _claimed
) public onlyOwner {
require(claimants[_claimant].claim > 0, "Claimant not found!");
claimants[_claimant] = Claimant(
_claim,
_firstClaimAt,
_claimCooldown,
_claimCount,
_claimed
);
emit ClaimantUpdated(
_claimant,
_claim,
_claimCooldown,
_claimCount,
_firstClaimAt,
_claimed
);
}
function _getAmountToClaim(address _claimant) internal view returns (uint256) {
Claimant storage claimant = claimants[_claimant];
require(claimant.claim > 0, "Claimant not found!");
require(block.timestamp >= claimant.firstClaimAt, "Claiming period has not started");
uint256 totalPossibleClaim = claimant.claim * claimant.claimCount;
if (claimant.claimed >= totalPossibleClaim) {
return 0;
}
uint256 periodsPassed = 1 + ((block.timestamp - claimant.firstClaimAt) / claimant.claimCooldown);
uint256 eligiblePeriods = periodsPassed > claimant.claimCount ?
claimant.claimCount :
periodsPassed;
uint256 totalEligible = eligiblePeriods * claimant.claim;
if (totalEligible <= claimant.claimed) {
return 0;
}
return totalEligible - claimant.claimed;
}
function claim() public ifNotPaused nonReentrant {
uint256 amountToClaim = _getAmountToClaim(msg.sender);
require(amountToClaim > 0, "No claimable amount");
claimants[msg.sender].claimed += amountToClaim;
IERC20(tokenAddress).safeTransfer(msg.sender, amountToClaim);
emit TokensClaimed(msg.sender, amountToClaim);
}
}
SafeERC20.sol 199 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
TokenAccessControl.sol 70 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract TokenAccessControl {
bool public paused = false;
address public owner;
address public newContractOwner;
mapping(address => bool) public authorizedContracts;
event SetPause(bool pause);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event AuthorizedUserSet(address indexed operator, bool approve);
constructor() {
owner = msg.sender;
}
modifier ifNotPaused() {
require(!paused, "contract is paused");
_;
}
modifier onlyOwner() {
require(msg.sender == owner, "caller is not an owner");
_;
}
modifier onlyAuthorizedUser() {
require(authorizedContracts[msg.sender], "caller is not an authorized user");
_;
}
modifier onlyOwnerOrAuthorizedUser() {
require(authorizedContracts[msg.sender] || msg.sender == owner, "caller is not an authorized user or an owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newContractOwner = _newOwner;
}
function acceptOwnership() public ifNotPaused {
require(msg.sender == newContractOwner);
emit OwnershipTransferred(owner, newContractOwner);
owner = newContractOwner;
newContractOwner = address(0);
}
function setAuthorizedUser(address _operator, bool _approve) public onlyOwner {
if (_approve) {
authorizedContracts[_operator] = true;
} else {
delete authorizedContracts[_operator];
}
emit AuthorizedUserSet(_operator, _approve);
}
function setPause(bool _paused) public onlyOwner {
paused = _paused;
if (paused) {
emit SetPause(paused);
}
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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);
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
Address.sol 150 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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 Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @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
* {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);
}
(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 {Errors.FailedCall}) 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 {Errors.FailedCall} 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 {Errors.FailedCall}.
*/
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
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
Errors.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
Read Contract
authorizedContracts 0xd5b9221b → bool
claimants 0x171c41af → uint256, uint256, uint256, uint256, uint256
newContractOwner 0x0de959cc → address
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
tokenAddress 0x9d76ea58 → address
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
acceptOwnership 0x79ba5097
No parameters
addClaimant 0x037d2643
address _claimant
uint256 _claim
uint256 _claimCooldown
uint256 _claimCount
uint256 _firstClaimAt
claim 0x4e71d92d
No parameters
renounceOwnership 0x715018a6
No parameters
setAuthorizedUser 0xa249225e
address _operator
bool _approve
setClaimantClaim 0x0379fefa
address _claimant
uint256 _claim
uint256 _claimCooldown
uint256 _claimCount
uint256 _firstClaimAt
uint256 _claimed
setPause 0xbedb86fb
bool _paused
setTokenAddress 0x26a4e8d2
address _tokenAddress
transferOwnership 0xf2fde38b
address _newOwner
Recent Transactions
No transactions found for this address