More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 573 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim | 21471168 | 23 hrs ago | IN | 0 ETH | 0.00033923 | ||||
Unstake | 21408456 | 9 days ago | IN | 0 ETH | 0.00205599 | ||||
Claim | 21378447 | 13 days ago | IN | 0 ETH | 0.00088532 | ||||
Claim | 21272463 | 28 days ago | IN | 0 ETH | 0.00100135 | ||||
Claim | 21270635 | 29 days ago | IN | 0 ETH | 0.00055035 | ||||
Claim | 21206487 | 37 days ago | IN | 0 ETH | 0.00056454 | ||||
Claim | 21186412 | 40 days ago | IN | 0 ETH | 0.00200589 | ||||
Claim | 20720673 | 105 days ago | IN | 0 ETH | 0.00085913 | ||||
Unstake | 20526612 | 132 days ago | IN | 0 ETH | 0.00038995 | ||||
Unstake | 20526592 | 132 days ago | IN | 0 ETH | 0.00054057 | ||||
Unstake | 20526585 | 132 days ago | IN | 0 ETH | 0.00046438 | ||||
Claim | 20526576 | 132 days ago | IN | 0 ETH | 0.00013768 | ||||
Claim | 20506228 | 135 days ago | IN | 0 ETH | 0.0001633 | ||||
Claim | 20468607 | 140 days ago | IN | 0 ETH | 0.00021881 | ||||
Unstake | 20385072 | 152 days ago | IN | 0 ETH | 0.00118472 | ||||
Claim | 20384749 | 152 days ago | IN | 0 ETH | 0.00032668 | ||||
Claim | 20190906 | 179 days ago | IN | 0 ETH | 0.00056088 | ||||
Claim | 20077902 | 195 days ago | IN | 0 ETH | 0.00127689 | ||||
Claim | 20076550 | 195 days ago | IN | 0 ETH | 0.00122606 | ||||
Claim | 20076232 | 195 days ago | IN | 0 ETH | 0.00168598 | ||||
Claim | 20076226 | 195 days ago | IN | 0 ETH | 0.00170905 | ||||
Claim | 20068614 | 196 days ago | IN | 0 ETH | 0.0009187 | ||||
Claim | 20067092 | 197 days ago | IN | 0 ETH | 0.00035551 | ||||
Claim | 20062261 | 197 days ago | IN | 0 ETH | 0.00090167 | ||||
Claim | 20062160 | 197 days ago | IN | 0 ETH | 0.00109446 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
Staking
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9; import "./interfaces/IERC721Receiver.sol"; import "./ERC/ERC721.sol"; import "./utils/Context.sol"; import "./AMMO.sol"; /** * @dev Implementation of a staking contract that receives custody of a user's Non Fungible Tokens to generate ERC20 tokens. * The contracts stakes immediately the Non Fungible Token upon reception and retains the original owner as the rightful owner with ownerOf mapping. * The original users retains the rights to stop staking at anytime therefore receiving its earning and the full custody and ownership of its Non Fungible Tokens. * User can claim its ERC20 earnings at anytime. */ contract Staking is IERC721Receiver, Context { using Address for address; using Strings for uint256; /** *@dev emitted when '_user' claims its earnings and sends '_amount' to it */ event Claim(address _user, uint _amount); /** *@dev emitted on reception and staking of '_tokenId' token from '_user'. */ event Stake(address _user, uint _tokenId); /** *@dev emitted when '_user' unstakes '_tokenId' token. */ event Unstake(address _user, uint _tokenId); // The base formula to define how much ERC20 is minted per day. uint private rewardSpeed; // Address of NFT collection contract address public whiteListedContract; // Address of the owner of this contract. address private owner; // The staking informations of a user mapping( address => StakingInfo) public stakingInfo; // The owner of a token in custody in this contract. To ensure that the original sender retains ownership. mapping(uint => address) private _ownerOf; //The NFT collection contract ERC721 public CHAMPS; //The ERC20 token contract AMMO public ammo; /** *@notice Structure containing all the staking informations of an address. *@dev lastClaim is in epoch time. */ struct StakingInfo { uint stakedNftNum; //Number of tokens from owner currently in staking uint multiplier; // Modifies ERC20 token generations speed uint claimed; // All ERC20 claimed by user until now uint lastClaim; //Last time of ERC20 claim mapping(uint => uint) tokenIds; // a list of tokenIds by index. Use stakedNftNum to enumerate all tokenIds in staking. } modifier onlyOwner() { require(_msgSender() == owner, "only owner"); _; } /** * @dev Initializes the contract and sets the owner . */ constructor(address _whiteListedContract, uint _rewardSpeed, address _owner) { owner = _owner; whiteListedContract = address(_whiteListedContract); rewardSpeed = _rewardSpeed; CHAMPS = ERC721(whiteListedContract); } /** *@dev sets the address of the ERC20 Ammo contract that will be used for minting new tokens. */ function setERC20(address _contractAddress) external onlyOwner { require(_contractAddress.isContract(), "is not a contract"); ammo = AMMO(_contractAddress); } /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) { require(address(whiteListedContract) == msg.sender, "wrong contract address"); _stake(tokenId, from); return IERC721Receiver.onERC721Received.selector; } /** * @notice It stakes the token upon reception in the contract. Only called on reception from OnERC721Received(). * All ERC20 already earned is automatically claimed and transfered to user. * The NFT of the sender is now in custody of this contract but original owner retains ownership. see { ownerOf() }. * @dev mapping owner of is to ensure that the original owner retains the right of claiming back its token at anytime. * @param _tokenId The id of the token to stake. * @param _from The owner of the NFT that is staked on this contract. * Emits a {Stake} event */ function _stake(uint _tokenId, address _from) private { require(msg.sender == whiteListedContract, "base contract only"); StakingInfo storage copy = stakingInfo[_from]; //copy to store data if (copy.stakedNftNum > 0) _claim(_from); //make sure to claim only if NFT were already staked //Update user staking informations stakingInfo[_from].lastClaim = block.timestamp; stakingInfo[_from].multiplier = 10 + (copy.stakedNftNum * 10 + (copy.stakedNftNum)); // add 1.1 every time stakingInfo[_from].tokenIds[stakingInfo[_from].stakedNftNum ] = _tokenId; // store the tokenId stakingInfo[_from].stakedNftNum = copy.stakedNftNum +1; _ownerOf[_tokenId] = _from; // user is owner of staked token emit Stake(_from, _tokenId); } /** * @notice it unstakes a NFT and sends it back to its owner. Called by user interaction. * It automatically claims and send ERC20 already earned to the user. * @dev * @param _index the id of the token to unstake and claim back * Emits a {Unstake} event */ function unstake(uint _index) external { uint tokenId = stakingInfo[_msgSender()].tokenIds[_index]; require(_ownerOf[tokenId] == _msgSender(), "not owner or staked"); StakingInfo storage copy = stakingInfo[_msgSender()]; _claim(_msgSender()); // claim gains and creates ERC20 tokens into the user's address //Update user staking informations (copy.stakedNftNum > 1) ? stakingInfo[_msgSender()].multiplier = copy.multiplier - 11 : stakingInfo[_msgSender()].multiplier = 0; stakingInfo[_msgSender()].stakedNftNum = copy.stakedNftNum - 1; //Keeps track ofhow many NFT are in staking stakingInfo[_msgSender()].tokenIds[_index] = stakingInfo[_msgSender()].tokenIds[stakingInfo[_msgSender()].stakedNftNum]; // tokenId is replaced by last in array stakingInfo[_msgSender()].tokenIds[stakingInfo[_msgSender()].stakedNftNum] = 0; //last in array is deleted _ownerOf[tokenId] = address(0); // This contract doesn't retain an owner. CHAMPS.safeTransferFrom(address(this), _msgSender(), tokenId); // Token is unlocked and sent back to owner emit Unstake(_msgSender(), tokenId); } /** * @notice The ERC20 generation speed is set by this function. * It depends on how many NFTs the user has staked in this contract. * @param _user the user's struct with its parameters. * @dev the base rate is 100 $AMMO per day. */ function _toClaim(address _user) internal view returns(uint){ StakingInfo storage SI = stakingInfo[_user]; uint toClaim = 10 ** 18 * (block.timestamp - SI.lastClaim) * (SI.multiplier / 10) / rewardSpeed; return toClaim; } /** * @notice That function allows user to manually claim its gains at anytime. * @dev public function that can be called by this contract or an external account. * Emits a {} event */ function claim() public { _claim(_msgSender()); } /** * @notice Internal function to claim ERC20 tokens earned by a user and send them to it. * @dev safeTransferFrom() (see {ERC721}) is called by the registered collection contract. * This contract needing to claim the user's earnings, it cannot call msg.sender that is the NFT collection contract address. * This function is only called during reception of the safeTransferFrom() and therefore needs the user's address as a parameter. * @param _from The address of the address to claim the gains for. * Emits a {Claim} event */ function _claim(address _from) internal { uint toClaim = _toClaim(_from); stakingInfo[_from].lastClaim = block.timestamp; stakingInfo[_from].claimed += toClaim; ammo.mint(_from, toClaim); emit Claim(_from, toClaim); } /** *@notice The NFT is now on contract address and in the original NFT contract it appears as the owner. * This function shows that the user that sent its NFT to the contract retains ownership. *@param _tokenId the token idof the NFT to view */ function ownerOf(uint _tokenId) external view returns(address) { return _ownerOf[_tokenId]; } /** *@notice Returns the amount of ERC20 tokens generated that a user can claim */ function checkToClaim() public view returns(uint) { return _toClaim(_msgSender()); } /** *@dev allows to change the base ERC20 generation speed of staking.Only owner can call. */ function updateRewardSpeed(uint _rewardSpeed) external onlyOwner { rewardSpeed = _rewardSpeed; } /** *@notice used to check what tokenIds are staked by a user *@dev to use with stakedNftNum for enumeration. *@param _index the index at which the tokenId is stored *@param _user the user to call for verification of possessions */ function tokenIdByIndex(uint _index, address _user) external view returns(uint){ return stakingInfo[_user].tokenIds[_index]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.9; import "../interfaces/IERC721.sol"; import "../interfaces/IERC721Receiver.sol"; import "../interfaces/IERC721Metadata.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "./ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) _owners; // Mapping owner address to token count mapping(address => uint256) _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Receiver).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual { } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.9; /** * @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; } }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9; import "./ERC/ERC721.sol"; import "./ERC/ERC20.sol"; contract AMMO is ERC20("AMMO", "$AMMO"){ //address of the staking contract that will mint ERC20 $AMMO address public stakingContract; address public owner; /** *@param _stakingContract only the staking contract can mint new AMMO $tokens */ constructor(address _stakingContract, address _owner) { stakingContract = address(_stakingContract); owner = _owner; _mint(_owner, 50000 * 10 **18); } /** *@dev */ function mint(address _from,uint _amount) external { require(_msgSender() == stakingContract, "wrong contract address"); _mint(_from, _amount); } function burn(uint _amount) external { require( msg.sender == owner, "only owner"); _burn(owner, _amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.9; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.9; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.9; import "../interfaces/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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.9; import "../interfaces/IERC20.sol"; import "../interfaces/IERC20Metadata.sol"; import "../utils/Context.sol"; import "./ERC165.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata, ERC165 { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) { return interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_whiteListedContract","type":"address"},{"internalType":"uint256","name":"_rewardSpeed","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Unstake","type":"event"},{"inputs":[],"name":"CHAMPS","outputs":[{"internalType":"contract ERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ammo","outputs":[{"internalType":"contract AMMO","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkToClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"}],"name":"setERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakingInfo","outputs":[{"internalType":"uint256","name":"stakedNftNum","type":"uint256"},{"internalType":"uint256","name":"multiplier","type":"uint256"},{"internalType":"uint256","name":"claimed","type":"uint256"},{"internalType":"uint256","name":"lastClaim","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"tokenIdByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardSpeed","type":"uint256"}],"name":"updateRewardSpeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whiteListedContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50604051610b5c380380610b5c83398101604081905261002f91610091565b600280546001600160a01b039283166001600160a01b031991821617909155600180549490921693811684179091556000919091556005805490911690911790556100cd565b80516001600160a01b038116811461008c57600080fd5b919050565b6000806000606084860312156100a657600080fd5b6100af84610075565b9250602084015191506100c460408501610075565b90509250925092565b610a80806100dc6000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063852ea4d411610071578063852ea4d4146101a057806394eecb50146101a8578063ac7ed874146101ff578063c29a6fda14610212578063dc11e12f14610225578063ded611221461023857600080fd5b80630ad1f3ba146100b9578063150b7a02146100e95780632e17de78146101155780632fbcedd21461012a5780634e71d92d1461016f5780636352211e14610177575b600080fd5b6005546100cc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100fc6100f73660046108c2565b61024b565b6040516001600160e01b031990911681526020016100e0565b61012861012336600461095d565b6102c2565b005b610161610138366004610976565b6001600160a01b0316600090815260036020908152604080832093835260049093019052205490565b6040519081526020016100e0565b6101286104b5565b6100cc61018536600461095d565b6000908152600460205260409020546001600160a01b031690565b6101616104c0565b6101df6101b63660046109a2565b600360208190526000918252604090912080546001820154600283015492909301549092919084565b6040805194855260208501939093529183015260608201526080016100e0565b61012861020d36600461095d565b6104d0565b6101286102203660046109a2565b610525565b6001546100cc906001600160a01b031681565b6006546100cc906001600160a01b031681565b6001546000906001600160a01b031633146102a65760405162461bcd60e51b815260206004820152601660248201527577726f6e6720636f6e7472616374206164647265737360501b60448201526064015b60405180910390fd5b6102b084866105e2565b50630a85bd0160e11b95945050505050565b336000818152600360209081526040808320858452600490810183528184205480855292529091205490916001600160a01b039091161461033b5760405162461bcd60e51b81526020600482015260136024820152721b9bdd081bdddb995c881bdc881cdd185ad959606a1b604482015260640161029d565b3360008181526003602052604090209061035490610744565b80546001106103775733600090815260036020526040812060010181905561039e565b600b816001015461038891906109da565b3360009081526003602052604090206001018190555b5080546103ad906001906109da565b336000818152600360209081526040808320858155948352600480860183528184205489855282852055945483528083208390558683529084905280822080546001600160a01b03191690556005548151632142170760e11b81523095810195909552602485019390935260448401869052516001600160a01b03909216926342842e0e926064808301939282900301818387803b15801561044e57600080fd5b505af1158015610462573d6000803e3d6000fd5b505050507f85082129d87b2fe11527cb1b3b7a520aeb5aa6913f88a3d8757fe40d1db02fdd61048e3390565b604080516001600160a01b03909216825260208201859052015b60405180910390a1505050565b6104be33610744565b565b60006104cb3361083b565b905090565b6002546001600160a01b0316336001600160a01b0316146105205760405162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015260640161029d565b600055565b6002546001600160a01b0316336001600160a01b0316146105755760405162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015260640161029d565b6001600160a01b0381163b6105c05760405162461bcd60e51b81526020600482015260116024820152701a5cc81b9bdd08184818dbdb9d1c9858dd607a1b604482015260640161029d565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146106315760405162461bcd60e51b81526020600482015260126024820152716261736520636f6e7472616374206f6e6c7960701b604482015260640161029d565b6001600160a01b03811660009081526003602052604090208054156106595761065982610744565b6001600160a01b038216600090815260036020819052604090912042910155805461068581600a6109f1565b61068f9190610a10565b61069a90600a610a10565b6001600160a01b038316600090815260036020908152604080832060018082019590955580548452600401909152902084905581546106d891610a10565b6001600160a01b038316600081815260036020908152604080832094909455868252600481529083902080546001600160a01b03191683179055825191825281018590527febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a91016104a8565b600061074f8261083b565b6001600160a01b03831660009081526003602081905260408220429181019190915560020180549293508392909190610789908490610a10565b90915550506006546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b1580156107dc57600080fd5b505af11580156107f0573d6000803e3d6000fd5b5050604080516001600160a01b0386168152602081018590527f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4935001905060405180910390a15050565b6001600160a01b03811660009081526003602052604081208154600182015483919061086990600a90610a28565b600384015461087890426109da565b61088a90670de0b6b3a76400006109f1565b61089491906109f1565b61089e9190610a28565b949350505050565b80356001600160a01b03811681146108bd57600080fd5b919050565b6000806000806000608086880312156108da57600080fd5b6108e3866108a6565b94506108f1602087016108a6565b935060408601359250606086013567ffffffffffffffff8082111561091557600080fd5b818801915088601f83011261092957600080fd5b81358181111561093857600080fd5b89602082850101111561094a57600080fd5b9699959850939650602001949392505050565b60006020828403121561096f57600080fd5b5035919050565b6000806040838503121561098957600080fd5b82359150610999602084016108a6565b90509250929050565b6000602082840312156109b457600080fd5b6109bd826108a6565b9392505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156109ec576109ec6109c4565b500390565b6000816000190483118215151615610a0b57610a0b6109c4565b500290565b60008219821115610a2357610a236109c4565b500190565b600082610a4557634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220dc7036a70556cae8c7c5d70bfa2f7be0760120ebd126b74c2409d0cd99af6fc364736f6c6343000809003300000000000000000000000097a923ed35351a1382e6bcbb5239fc8d933600850000000000000000000000000000000000000000000000000000000000000360000000000000000000000000107cd8d7b9080542b6b576ca6457cbab5a9526bb
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063852ea4d411610071578063852ea4d4146101a057806394eecb50146101a8578063ac7ed874146101ff578063c29a6fda14610212578063dc11e12f14610225578063ded611221461023857600080fd5b80630ad1f3ba146100b9578063150b7a02146100e95780632e17de78146101155780632fbcedd21461012a5780634e71d92d1461016f5780636352211e14610177575b600080fd5b6005546100cc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100fc6100f73660046108c2565b61024b565b6040516001600160e01b031990911681526020016100e0565b61012861012336600461095d565b6102c2565b005b610161610138366004610976565b6001600160a01b0316600090815260036020908152604080832093835260049093019052205490565b6040519081526020016100e0565b6101286104b5565b6100cc61018536600461095d565b6000908152600460205260409020546001600160a01b031690565b6101616104c0565b6101df6101b63660046109a2565b600360208190526000918252604090912080546001820154600283015492909301549092919084565b6040805194855260208501939093529183015260608201526080016100e0565b61012861020d36600461095d565b6104d0565b6101286102203660046109a2565b610525565b6001546100cc906001600160a01b031681565b6006546100cc906001600160a01b031681565b6001546000906001600160a01b031633146102a65760405162461bcd60e51b815260206004820152601660248201527577726f6e6720636f6e7472616374206164647265737360501b60448201526064015b60405180910390fd5b6102b084866105e2565b50630a85bd0160e11b95945050505050565b336000818152600360209081526040808320858452600490810183528184205480855292529091205490916001600160a01b039091161461033b5760405162461bcd60e51b81526020600482015260136024820152721b9bdd081bdddb995c881bdc881cdd185ad959606a1b604482015260640161029d565b3360008181526003602052604090209061035490610744565b80546001106103775733600090815260036020526040812060010181905561039e565b600b816001015461038891906109da565b3360009081526003602052604090206001018190555b5080546103ad906001906109da565b336000818152600360209081526040808320858155948352600480860183528184205489855282852055945483528083208390558683529084905280822080546001600160a01b03191690556005548151632142170760e11b81523095810195909552602485019390935260448401869052516001600160a01b03909216926342842e0e926064808301939282900301818387803b15801561044e57600080fd5b505af1158015610462573d6000803e3d6000fd5b505050507f85082129d87b2fe11527cb1b3b7a520aeb5aa6913f88a3d8757fe40d1db02fdd61048e3390565b604080516001600160a01b03909216825260208201859052015b60405180910390a1505050565b6104be33610744565b565b60006104cb3361083b565b905090565b6002546001600160a01b0316336001600160a01b0316146105205760405162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015260640161029d565b600055565b6002546001600160a01b0316336001600160a01b0316146105755760405162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015260640161029d565b6001600160a01b0381163b6105c05760405162461bcd60e51b81526020600482015260116024820152701a5cc81b9bdd08184818dbdb9d1c9858dd607a1b604482015260640161029d565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146106315760405162461bcd60e51b81526020600482015260126024820152716261736520636f6e7472616374206f6e6c7960701b604482015260640161029d565b6001600160a01b03811660009081526003602052604090208054156106595761065982610744565b6001600160a01b038216600090815260036020819052604090912042910155805461068581600a6109f1565b61068f9190610a10565b61069a90600a610a10565b6001600160a01b038316600090815260036020908152604080832060018082019590955580548452600401909152902084905581546106d891610a10565b6001600160a01b038316600081815260036020908152604080832094909455868252600481529083902080546001600160a01b03191683179055825191825281018590527febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a91016104a8565b600061074f8261083b565b6001600160a01b03831660009081526003602081905260408220429181019190915560020180549293508392909190610789908490610a10565b90915550506006546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b1580156107dc57600080fd5b505af11580156107f0573d6000803e3d6000fd5b5050604080516001600160a01b0386168152602081018590527f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4935001905060405180910390a15050565b6001600160a01b03811660009081526003602052604081208154600182015483919061086990600a90610a28565b600384015461087890426109da565b61088a90670de0b6b3a76400006109f1565b61089491906109f1565b61089e9190610a28565b949350505050565b80356001600160a01b03811681146108bd57600080fd5b919050565b6000806000806000608086880312156108da57600080fd5b6108e3866108a6565b94506108f1602087016108a6565b935060408601359250606086013567ffffffffffffffff8082111561091557600080fd5b818801915088601f83011261092957600080fd5b81358181111561093857600080fd5b89602082850101111561094a57600080fd5b9699959850939650602001949392505050565b60006020828403121561096f57600080fd5b5035919050565b6000806040838503121561098957600080fd5b82359150610999602084016108a6565b90509250929050565b6000602082840312156109b457600080fd5b6109bd826108a6565b9392505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156109ec576109ec6109c4565b500390565b6000816000190483118215151615610a0b57610a0b6109c4565b500290565b60008219821115610a2357610a236109c4565b500190565b600082610a4557634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220dc7036a70556cae8c7c5d70bfa2f7be0760120ebd126b74c2409d0cd99af6fc364736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000097a923ed35351a1382e6bcbb5239fc8d933600850000000000000000000000000000000000000000000000000000000000000360000000000000000000000000107cd8d7b9080542b6b576ca6457cbab5a9526bb
-----Decoded View---------------
Arg [0] : _whiteListedContract (address): 0x97a923ed35351a1382E6bcbB5239fc8d93360085
Arg [1] : _rewardSpeed (uint256): 864
Arg [2] : _owner (address): 0x107cD8d7b9080542B6B576Ca6457CBAb5A9526bB
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000097a923ed35351a1382e6bcbb5239fc8d93360085
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000360
Arg [2] : 000000000000000000000000107cd8d7b9080542b6b576ca6457cbab5a9526bb
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.