Address Contract Verified
Address
0x4CD11AfB60557D1565ea37F639C8455A8530c2A4
Balance
0 ETH
Nonce
1
Code Size
5315 bytes
Creator
0xC946cB23...7FcD at tx 0xea32fa42...463ea6
Indexed Transactions
0
Contract Bytecode
5315 bytes
0x6080604052600436106101125760003560e01c8063a035b1fe116100a5578063d80efffd11610074578063ed60e1f011610059578063ed60e1f0146102da578063f2fde38b1461031d578063f5d3cca31461033d57600080fd5b8063d80efffd146102a7578063d96a094a146102c757600080fd5b8063a035b1fe14610210578063c5ac1a3214610226578063c884ef8314610246578063d5abeb011461027357600080fd5b8063715018a6116100e1578063715018a614610190578063771282f6146101a557806384955c88146101bb5780638da5cb5b146101db57600080fd5b80633ccfd60b1461011e5780634e71d92d1461012857806355a3b2c11461013d5780636f9fb98a1461017d57600080fd5b3661011957005b600080fd5b61012661035d565b005b34801561013457600080fd5b506101266103cf565b34801561014957600080fd5b5061016a61015836600461112d565b60066020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561018957600080fd5b504761016a565b34801561019c57600080fd5b506101266105c2565b3480156101b157600080fd5b5061016a60055481565b3480156101c757600080fd5b5061016a6101d636600461112d565b6105d6565b3480156101e757600080fd5b5060015460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610174565b34801561021c57600080fd5b5061016a60045481565b34801561023257600080fd5b5061012661024136600461112d565b610735565b34801561025257600080fd5b5061016a61026136600461112d565b60076020526000908152604090205481565b34801561027f57600080fd5b5061016a7f00000000000000000000000000000000000000000013da329b6336471800000081565b3480156102b357600080fd5b506101266102c236600461112d565b610784565b6101266102d5366004611148565b6107d3565b3480156102e657600080fd5b5061016a6102f536600461112d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526007602052604090205490565b34801561032957600080fd5b5061012661033836600461112d565b6109de565b34801561034957600080fd5b5061012661035836600461126e565b610a44565b610365610d16565b600061038660015473ffffffffffffffffffffffffffffffffffffffff1690565b60405190915073ffffffffffffffffffffffffffffffffffffffff8216904780156108fc02916000818181858888f193505050501580156103cb573d6000803e3d6000fd5b5050565b326000908152600660205260408120549003610417576040517ff4a9469d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000620186a0610426326105d6565b610430919061135d565b326000908152600760205260408120549192509061044e9083611398565b326000908152600760205260408120805492935083929091906104729084906113ab565b90915550506003546040517f79cc67900000000000000000000000000000000000000000000000000000000081523260048201526024810183905273ffffffffffffffffffffffffffffffffffffffff909116906379cc679090604401600060405180830381600087803b1580156104e957600080fd5b505af11580156104fd573d6000803e3d6000fd5b50506002546040517f095ea7b30000000000000000000000000000000000000000000000000000000081523060048201526024810185905273ffffffffffffffffffffffffffffffffffffffff909116925063095ea7b391506044016020604051808303816000875af1158015610578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059c91906113be565b506002546103cb9073ffffffffffffffffffffffffffffffffffffffff16303284610d69565b6105ca610d16565b6105d46000610e04565b565b60006106227f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000066c6f1c76113ab565b42101561063157506000919050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600660205260409020547f0000000000000000000000000000000000000000000000000000000068a834e34211156106935761068c620186a0826113e0565b9392505050565b60006106df7f0000000000000000000000000000000000000000000000000000000066c6f1c77f0000000000000000000000000000000000000000000000000000000068a834e3611398565b620186a061070d7f0000000000000000000000000000000000000000000000000000000066c6f1c742611398565b61071791906113e0565b610721919061135d565b905061072d81836113e0565b949350505050565b61073d610d16565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61078c610d16565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6107db610e7b565b7f00000000000000000000000000000000000000000013da329b633647180000008160055461080a91906113ab565b1115610842576040517f90f5061e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60045460000361087e576040517f667feb3200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610890670de0b6b3a76400008261135d565b60045461089d91906113e0565b34146108d5576040517fb895737d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546040517f095ea7b30000000000000000000000000000000000000000000000000000000081523060048201526024810183905273ffffffffffffffffffffffffffffffffffffffff9091169063095ea7b3906044016020604051808303816000875af115801561094c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097091906113be565b506003546109969073ffffffffffffffffffffffffffffffffffffffff16303284610d69565b32600090815260066020526040812080548392906109b59084906113ab565b9250508190555080600560008282546109ce91906113ab565b9091555050600160005550565b50565b6109e6610d16565b73ffffffffffffffffffffffffffffffffffffffff8116610a3b576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b6109db81610e04565b610a4c610e7b565b610a54610d16565b60005b8251811015610d0b57600354825173ffffffffffffffffffffffffffffffffffffffff9091169063095ea7b3903090859085908110610a9857610a986113f7565b60200260200101516040518363ffffffff1660e01b8152600401610ade92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b6020604051808303816000875af1158015610afd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2191906113be565b50610b7e30848381518110610b3857610b386113f7565b6020026020010151848481518110610b5257610b526113f7565b602090810291909101015160035473ffffffffffffffffffffffffffffffffffffffff16929190610d69565b818181518110610b9057610b906113f7565b602002602001015160066000858481518110610bae57610bae6113f7565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610bff91906113ab565b92505081905550818181518110610c1857610c186113f7565b602002602001015160056000828254610c3191906113ab565b925050819055507f0000000000000000000000006a084832bf26ccd9446873cc33fecdfd7d2a77d073ffffffffffffffffffffffffffffffffffffffff16630faddafa848381518110610c8657610c866113f7565b60200260200101516040518263ffffffff1660e01b8152600401610cc6919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b600060405180830381600087803b158015610ce057600080fd5b505af1158015610cf4573d6000803e3d6000fd5b505050508080610d0390611426565b915050610a57565b506103cb6001600055565b60015473ffffffffffffffffffffffffffffffffffffffff1633146105d4576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610a32565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610dfe908590610ebe565b50505050565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600260005403610eb7576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600055565b6000610ee073ffffffffffffffffffffffffffffffffffffffff841683610f59565b90508051600014158015610f05575080806020019051810190610f0391906113be565b155b15610f54576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401610a32565b505050565b6060610f6783836000610f70565b90505b92915050565b606081471015610fae576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610a32565b6000808573ffffffffffffffffffffffffffffffffffffffff168486604051610fd7919061145e565b60006040518083038185875af1925050503d8060008114611014576040519150601f19603f3d011682016040523d82523d6000602084013e611019565b606091505b5091509150611029868383611033565b9695505050505050565b60608261104857611043826110c2565b61068c565b815115801561106c575073ffffffffffffffffffffffffffffffffffffffff84163b155b156110bb576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610a32565b508061068c565b8051156110d25780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff8116811461112857600080fd5b919050565b60006020828403121561113f57600080fd5b610f6782611104565b60006020828403121561115a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111d7576111d7611161565b604052919050565b600067ffffffffffffffff8211156111f9576111f9611161565b5060051b60200190565b600082601f83011261121457600080fd5b81356020611229611224836111df565b611190565b82815260059290921b8401810191818101908684111561124857600080fd5b8286015b84811015611263578035835291830191830161124c565b509695505050505050565b6000806040838503121561128157600080fd5b823567ffffffffffffffff8082111561129957600080fd5b818501915085601f8301126112ad57600080fd5b813560206112bd611224836111df565b82815260059290921b840181019181810190898411156112dc57600080fd5b948201945b83861015611301576112f286611104565b825294820194908201906112e1565b9650508601359250508082111561131757600080fd5b5061132485828601611203565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082611393577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115610f6a57610f6a61132e565b80820180821115610f6a57610f6a61132e565b6000602082840312156113d057600080fd5b8151801515811461068c57600080fd5b8082028115828204841417610f6a57610f6a61132e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036114575761145761132e565b5060010190565b6000825160005b8181101561147f5760208186018101518583015201611465565b50600092019182525091905056fea264697066735822122082c5353cbcb5270168ce2eb4ecf7102d2e38ca5df60d3b25bf00560bad7dfd2464736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: Yes (1000000 runs)
Vesting.sol 264 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IVestingManager} from "./interface/IVestingManager.sol";
// import {IERC20} from "./interface/IERC20.sol";
import {IERC20Burnable} from "./interface/IERC20Burnable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract Vesting is ReentrancyGuard, Ownable {
using SafeERC20 for IERC20;
using SafeERC20 for IERC20Burnable;
// =============== Constants ===============
/**
* @dev Equivalent of 100%
*/
uint256 private constant PERCENT_AMOUNT = 100;
/**
* @dev Seconds in year
*/
uint256 private constant SECONDS_IN_YEAR = 3.154e7;
/**
* @dev Constant for rounding
*/
uint256 private constant MULTIPLIER = 100000;
/**
* @dev Multiplier represent 10 ** 18 (decimals)
*/
uint256 private constant DECIMALS_MULTIPLIER = 10 ** 18;
// =============== Variables ===============
/**
* @dev Address of manager contract
*/
IVestingManager private immutable vestingManager;
/**
* @dev Contract of ERC20 token that represents unlocked tokens
*/
IERC20 private unlockedToken;
/**
* @dev Contract of ERC20 token that represents locked tokens
*/
IERC20Burnable private lockedToken;
/**
* @dev Duration of vesting
*/
uint256 private immutable duration;
/**
* @dev Duration of cliff
*/
uint256 private immutable cliff;
/**
* @dev Timestamp of vesting start
*/
uint256 private immutable startTime;
/**
* @dev Timestamp of ending of vesting
*/
uint256 private immutable endTime;
/**
* @dev Start fixed price of 1 token in wei
*/
uint256 public price;
/**
* @dev Current supply of tokens
*/
uint256 public currentSupply;
/**
* @dev Max supply of tokens
*/
uint256 public immutable maxSupply;
// =============== Mappings ===============
/**
* @dev Amount of users' minted tokens
*/
mapping(address => uint256) public amounts;
/**
* @dev Amount of claimed tokens by user
*/
mapping(address => uint256) public claimed;
// =============== Errors ===============
/**
* @dev Reverts if amount of user equal 0
*/
error NotHaveAmountOnThisVesting();
/**
* @dev Reverts if `msg.value` less or equal 0
*/
error NotCorrectValue();
/**
* @dev Reverts if totalSupply exceeds max supply
*/
error MoreThanMaxSupply();
/**
* @dev Reverts if vesting can't sell tokens (price = 0)
*/
error NotForPurchase();
constructor(
address _managerAddress,
address _owner,
uint256 _maxSupply,
uint256 initialPrice,
uint256 _duration,
uint256 _cliff
) Ownable(_owner) {
vestingManager = IVestingManager(_managerAddress);
duration = _duration;
cliff = _cliff;
startTime = block.timestamp + cliff;
endTime = startTime + duration;
maxSupply = _maxSupply;
price = initialPrice;
}
/**
* @dev Function for buying tokens
* @param amount Amount for buying
*/
function buy(uint256 amount) external payable nonReentrant {
if (currentSupply + amount > maxSupply) revert MoreThanMaxSupply();
if (price == 0) revert NotForPurchase();
if (msg.value != price * (amount / DECIMALS_MULTIPLIER)) {
revert NotCorrectValue();
}
lockedToken.approve(address(this), amount);
lockedToken.safeTransferFrom(address(this), tx.origin, amount);
amounts[tx.origin] += amount;
currentSupply += amount;
}
/**
* @dev Function for transferring locked tokens for users
* @param userAddresses Addresses who will receive tokens amountsForTransfer
* @param amountsForTransfer Amount of transferring tokens
*/
function transferLockedTokens(
address[] memory userAddresses,
uint256[] memory amountsForTransfer
) public nonReentrant onlyOwner {
for (uint256 i; i < userAddresses.length; i++) {
lockedToken.approve(address(this), amountsForTransfer[i]);
lockedToken.safeTransferFrom(
address(this),
userAddresses[i],
amountsForTransfer[i]
);
amounts[userAddresses[i]] += amountsForTransfer[i];
currentSupply += amountsForTransfer[i];
vestingManager.setUserToVesting(userAddresses[i]);
}
}
/**
* @dev Function for claiming unlocked token amount
*/
function claim() external {
if (amounts[tx.origin] == 0) revert NotHaveAmountOnThisVesting();
uint256 unlockedAmount = unlockedBalanceOf(tx.origin) / MULTIPLIER;
// if claimed amount will not subtracted from `unlockedAmount`
// user be able to claim `unlockedAmount` many times
uint256 releasable = unlockedAmount - claimed[tx.origin];
claimed[tx.origin] += releasable;
lockedToken.burnFrom(tx.origin, releasable);
unlockedToken.approve(address(this), releasable);
unlockedToken.safeTransferFrom(address(this), tx.origin, releasable);
}
/**
* @dev Returns amount of unlocked tokens of `userAddress`
* @notice Amount multiplied by `MULTIPLIER`
* @param userAddress Address of token holder
* @return Amount of unlocked tokens
*/
function unlockedBalanceOf(
address userAddress
) public view returns (uint256) {
if (block.timestamp < startTime + cliff) return 0;
uint256 amount = amounts[userAddress];
if (block.timestamp > endTime) return amount * MULTIPLIER;
uint256 multiplier = ((block.timestamp - startTime) * MULTIPLIER) /
(endTime - startTime);
return amount * multiplier;
}
/**
* @dev Function for withdrawing ethers by owner
*/
function withdraw() external payable onlyOwner {
address payable owner = payable(owner());
owner.transfer(address(this).balance);
}
function setLockedToken(address _lockedToken) public onlyOwner {
lockedToken = IERC20Burnable(_lockedToken);
}
function setUnockedToken(address _unlockedToken) public onlyOwner {
unlockedToken = IERC20(_unlockedToken);
}
/**
* @dev Getter function for getting info how many tokens user have already claimed
* @param userAddress Address of token holder
* @return Amount of claimed unlocked tokens
*/
function getUsersClaimed(
address userAddress
) public view returns (uint256) {
return claimed[userAddress];
}
/**
* @dev Function for getting balance from contract
* @return Balance of eth
*/
function getContractBalance() public view returns (uint256) {
return address(this).balance;
}
receive() external payable {}
}
IERC20Burnable.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IERC20Burnable is IERC20 {
function mint(address to, uint256 amount) external;
function burn(uint256 value) external;
function burnFrom(address account, uint256 value) external;
}
IVestingManager.sol 7 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IVestingManager {
function setUserToVesting(address userAddress) external;
function setVesting(address _vestingAddress) external;
}
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;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
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);
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 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;
}
}
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;
}
}
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
amounts 0x55a3b2c1 → uint256
claimed 0xc884ef83 → uint256
currentSupply 0x771282f6 → uint256
getContractBalance 0x6f9fb98a → uint256
getUsersClaimed 0xed60e1f0 → uint256
maxSupply 0xd5abeb01 → uint256
owner 0x8da5cb5b → address
price 0xa035b1fe → uint256
unlockedBalanceOf 0x84955c88 → uint256
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
buy 0xd96a094a
uint256 amount
claim 0x4e71d92d
No parameters
renounceOwnership 0x715018a6
No parameters
setLockedToken 0xd80efffd
address _lockedToken
setUnockedToken 0xc5ac1a32
address _unlockedToken
transferLockedTokens 0xf5d3cca3
address[] userAddresses
uint256[] amountsForTransfer
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address