Transactions
Token Transfers
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- GiftDispenser
- Optimization enabled
- false
- Compiler version
- v0.8.17+commit.8df45f5f
- EVM Version
- default
- Verified at
- 2024-09-26T15:31:52.584495Z
Contract source code
// File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; /** * @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. * * By default, the owner account will be the one that deploys the contract. 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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); } } // File: xmas/Minter.sol pragma solidity ^0.8.12; interface NFTInterface { function mintWithClass(uint256 classId) external returns (uint256 _newTokenID); function transfer(address _to, uint256 _tokenId, bytes calldata _data) external returns (bool); function addPropertyWithContent(uint256 _tokenId, string calldata _content) external; } contract GiftDispenser is Ownable{ address public nftAddress; bool public isPaused; event GiftSent(address indexed to, uint class); mapping (address => uint256) public naugthyList; modifier paused() { require(!isPaused, "Function: paused"); _; } function pause() public onlyOwner{ isPaused = true; } function unpause() public onlyOwner{ isPaused = false; } function setNFTAddress(address _nftAddress) public onlyOwner { nftAddress = _nftAddress; } function addCS (address _csAddress, uint256 _csBalance) public onlyOwner { naugthyList[_csAddress] = _csBalance; } function removeCS (address _csAddress) internal { delete naugthyList[_csAddress]; } function getClass(uint256 userBalance) internal view returns (uint256){ if(userBalance > 2_500_000) { //returns 0, 1 or 2 return uint256(keccak256(abi.encodePacked(block.timestamp, userBalance))) % 3; } if(userBalance > 500_000) { //returns 3 or 4 return uint256(keccak256(abi.encodePacked(block.timestamp, userBalance))) % 2 + 3; } return 5; } function claimGift () public paused{ uint256 userBalance = naugthyList[msg.sender]; require(userBalance >= 10_000); uint256 classID = getClass(userBalance); uint256 _mintedId = NFTInterface(nftAddress).mintWithClass(classID); NFTInterface(nftAddress).transfer(msg.sender, _mintedId, ""); removeCS(msg.sender); emit GiftSent(msg.sender, classID); } }
Contract ABI
[{"type":"event","name":"GiftSent","inputs":[{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"class","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addCS","inputs":[{"type":"address","name":"_csAddress","internalType":"address"},{"type":"uint256","name":"_csBalance","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimGift","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPaused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"naugthyList","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"nftAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFTAddress","inputs":[{"type":"address","name":"_nftAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5061002d61002261003260201b60201c565b61003a60201b60201c565b6100fe565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610d948061010d6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80638456cb59116100715780638456cb591461012c5780638da5cb5b146101365780638f7c8d10146101545780639f5cb7251461015e578063b187bd261461017a578063f2fde38b14610198576100a9565b80633c37f687146100ae5780633f4ba83a146100de5780635bf8633a146100e857806369d0373814610106578063715018a614610122575b600080fd5b6100c860048036038101906100c39190610898565b6101b4565b6040516100d591906108de565b60405180910390f35b6100e66101cc565b005b6100f06101f1565b6040516100fd9190610908565b60405180910390f35b610120600480360381019061011b9190610898565b610217565b005b61012a610263565b005b610134610277565b005b61013e61029b565b60405161014b9190610908565b60405180910390f35b61015c6102c4565b005b6101786004803603810190610173919061094f565b610513565b005b610182610563565b60405161018f91906109aa565b60405180910390f35b6101b260048036038101906101ad9190610898565b610576565b005b60026020528060005260406000206000915090505481565b6101d46105f9565b6000600160146101000a81548160ff021916908315150217905550565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61021f6105f9565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61026b6105f9565b6102756000610677565b565b61027f6105f9565b60018060146101000a81548160ff021916908315150217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160149054906101000a900460ff1615610314576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030b90610a22565b60405180910390fd5b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061271081101561036757600080fd5b60006103728261073b565b90506000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633c65b3eb836040518263ffffffff1660e01b81526004016103d191906108de565b6020604051808303816000875af11580156103f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104149190610a57565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663be45fd6233836040518363ffffffff1660e01b8152600401610473929190610abb565b6020604051808303816000875af1158015610492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b69190610b23565b506104c0336107e7565b3373ffffffffffffffffffffffffffffffffffffffff167ff60843e7f75836e6a5aacf05ea1783d1a137a7c2980eea169f8bf57c87fca1ff8360405161050691906108de565b60405180910390a2505050565b61051b6105f9565b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b600160149054906101000a900460ff1681565b61057e6105f9565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036105ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e490610bc2565b60405180910390fd5b6105f681610677565b50565b61060161082d565b73ffffffffffffffffffffffffffffffffffffffff1661061f61029b565b73ffffffffffffffffffffffffffffffffffffffff1614610675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066c90610c2e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000622625a0821115610787576003428360405160200161075d929190610c6f565b6040516020818303038152906040528051906020012060001c6107809190610cca565b90506107e2565b6207a1208211156107dd576003600242846040516020016107a9929190610c6f565b6040516020818303038152906040528051906020012060001c6107cc9190610cca565b6107d69190610d2a565b90506107e2565b600590505b919050565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b600033905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108658261083a565b9050919050565b6108758161085a565b811461088057600080fd5b50565b6000813590506108928161086c565b92915050565b6000602082840312156108ae576108ad610835565b5b60006108bc84828501610883565b91505092915050565b6000819050919050565b6108d8816108c5565b82525050565b60006020820190506108f360008301846108cf565b92915050565b6109028161085a565b82525050565b600060208201905061091d60008301846108f9565b92915050565b61092c816108c5565b811461093757600080fd5b50565b60008135905061094981610923565b92915050565b6000806040838503121561096657610965610835565b5b600061097485828601610883565b92505060206109858582860161093a565b9150509250929050565b60008115159050919050565b6109a48161098f565b82525050565b60006020820190506109bf600083018461099b565b92915050565b600082825260208201905092915050565b7f46756e6374696f6e3a2070617573656400000000000000000000000000000000600082015250565b6000610a0c6010836109c5565b9150610a17826109d6565b602082019050919050565b60006020820190508181036000830152610a3b816109ff565b9050919050565b600081519050610a5181610923565b92915050565b600060208284031215610a6d57610a6c610835565b5b6000610a7b84828501610a42565b91505092915050565b600082825260208201905092915050565b50565b6000610aa5600083610a84565b9150610ab082610a95565b600082019050919050565b6000606082019050610ad060008301856108f9565b610add60208301846108cf565b8181036040830152610aee81610a98565b90509392505050565b610b008161098f565b8114610b0b57600080fd5b50565b600081519050610b1d81610af7565b92915050565b600060208284031215610b3957610b38610835565b5b6000610b4784828501610b0e565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610bac6026836109c5565b9150610bb782610b50565b604082019050919050565b60006020820190508181036000830152610bdb81610b9f565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610c186020836109c5565b9150610c2382610be2565b602082019050919050565b60006020820190508181036000830152610c4781610c0b565b9050919050565b6000819050919050565b610c69610c64826108c5565b610c4e565b82525050565b6000610c7b8285610c58565b602082019150610c8b8284610c58565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610cd5826108c5565b9150610ce0836108c5565b925082610cf057610cef610c9b565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610d35826108c5565b9150610d40836108c5565b9250828201905080821115610d5857610d57610cfb565b5b9291505056fea26469706673582212200ab1c14d7e31a9ffba70f2999feb78477f96ea3bf67146db0ff1598227ade98b64736f6c63430008110033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638456cb59116100715780638456cb591461012c5780638da5cb5b146101365780638f7c8d10146101545780639f5cb7251461015e578063b187bd261461017a578063f2fde38b14610198576100a9565b80633c37f687146100ae5780633f4ba83a146100de5780635bf8633a146100e857806369d0373814610106578063715018a614610122575b600080fd5b6100c860048036038101906100c39190610898565b6101b4565b6040516100d591906108de565b60405180910390f35b6100e66101cc565b005b6100f06101f1565b6040516100fd9190610908565b60405180910390f35b610120600480360381019061011b9190610898565b610217565b005b61012a610263565b005b610134610277565b005b61013e61029b565b60405161014b9190610908565b60405180910390f35b61015c6102c4565b005b6101786004803603810190610173919061094f565b610513565b005b610182610563565b60405161018f91906109aa565b60405180910390f35b6101b260048036038101906101ad9190610898565b610576565b005b60026020528060005260406000206000915090505481565b6101d46105f9565b6000600160146101000a81548160ff021916908315150217905550565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61021f6105f9565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61026b6105f9565b6102756000610677565b565b61027f6105f9565b60018060146101000a81548160ff021916908315150217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160149054906101000a900460ff1615610314576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030b90610a22565b60405180910390fd5b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061271081101561036757600080fd5b60006103728261073b565b90506000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633c65b3eb836040518263ffffffff1660e01b81526004016103d191906108de565b6020604051808303816000875af11580156103f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104149190610a57565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663be45fd6233836040518363ffffffff1660e01b8152600401610473929190610abb565b6020604051808303816000875af1158015610492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b69190610b23565b506104c0336107e7565b3373ffffffffffffffffffffffffffffffffffffffff167ff60843e7f75836e6a5aacf05ea1783d1a137a7c2980eea169f8bf57c87fca1ff8360405161050691906108de565b60405180910390a2505050565b61051b6105f9565b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b600160149054906101000a900460ff1681565b61057e6105f9565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036105ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e490610bc2565b60405180910390fd5b6105f681610677565b50565b61060161082d565b73ffffffffffffffffffffffffffffffffffffffff1661061f61029b565b73ffffffffffffffffffffffffffffffffffffffff1614610675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066c90610c2e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000622625a0821115610787576003428360405160200161075d929190610c6f565b6040516020818303038152906040528051906020012060001c6107809190610cca565b90506107e2565b6207a1208211156107dd576003600242846040516020016107a9929190610c6f565b6040516020818303038152906040528051906020012060001c6107cc9190610cca565b6107d69190610d2a565b90506107e2565b600590505b919050565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b600033905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108658261083a565b9050919050565b6108758161085a565b811461088057600080fd5b50565b6000813590506108928161086c565b92915050565b6000602082840312156108ae576108ad610835565b5b60006108bc84828501610883565b91505092915050565b6000819050919050565b6108d8816108c5565b82525050565b60006020820190506108f360008301846108cf565b92915050565b6109028161085a565b82525050565b600060208201905061091d60008301846108f9565b92915050565b61092c816108c5565b811461093757600080fd5b50565b60008135905061094981610923565b92915050565b6000806040838503121561096657610965610835565b5b600061097485828601610883565b92505060206109858582860161093a565b9150509250929050565b60008115159050919050565b6109a48161098f565b82525050565b60006020820190506109bf600083018461099b565b92915050565b600082825260208201905092915050565b7f46756e6374696f6e3a2070617573656400000000000000000000000000000000600082015250565b6000610a0c6010836109c5565b9150610a17826109d6565b602082019050919050565b60006020820190508181036000830152610a3b816109ff565b9050919050565b600081519050610a5181610923565b92915050565b600060208284031215610a6d57610a6c610835565b5b6000610a7b84828501610a42565b91505092915050565b600082825260208201905092915050565b50565b6000610aa5600083610a84565b9150610ab082610a95565b600082019050919050565b6000606082019050610ad060008301856108f9565b610add60208301846108cf565b8181036040830152610aee81610a98565b90509392505050565b610b008161098f565b8114610b0b57600080fd5b50565b600081519050610b1d81610af7565b92915050565b600060208284031215610b3957610b38610835565b5b6000610b4784828501610b0e565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610bac6026836109c5565b9150610bb782610b50565b604082019050919050565b60006020820190508181036000830152610bdb81610b9f565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610c186020836109c5565b9150610c2382610be2565b602082019050919050565b60006020820190508181036000830152610c4781610c0b565b9050919050565b6000819050919050565b610c69610c64826108c5565b610c4e565b82525050565b6000610c7b8285610c58565b602082019150610c8b8284610c58565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610cd5826108c5565b9150610ce0836108c5565b925082610cf057610cef610c9b565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610d35826108c5565b9150610d40836108c5565b9250828201905080821115610d5857610d57610cfb565b5b9291505056fea26469706673582212200ab1c14d7e31a9ffba70f2999feb78477f96ea3bf67146db0ff1598227ade98b64736f6c63430008110033