Overview
APE Balance
0 APE
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
7744448 | 27 days ago | 0.2 APE |
Loading...
Loading
Contract Name:
NFTSale
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; contract NFTSale { address public admin; address public nftContract; uint256 public price; uint256 public currentIndex; uint256 public endId; event Purchase(address indexed buyer, uint256 indexed tokenId); event PriceUpdated(uint256 newPrice); constructor( address _nftContract, uint256 _price, uint256 _startId, uint256 _endId ) { admin = msg.sender; nftContract = _nftContract; price = _price; currentIndex = _startId; endId = _endId; } modifier onlyAdmin() { require(msg.sender == admin, "Only admin can perform this action"); _; } function updatePrice(uint256 _newPrice) external onlyAdmin { price = _newPrice; emit PriceUpdated(_newPrice); } function purchase() external payable { require(currentIndex <= endId, "All NFTs sold out"); require(msg.value == price, "Incorrect payment amount"); uint256 tokenId = currentIndex; currentIndex++; IERC721(nftContract).transferFrom(admin, msg.sender, tokenId); emit Purchase(msg.sender, tokenId); } function withdraw() external onlyAdmin { payable(admin).transfer(address(this).balance); } function getRemainingNFTs() external view returns (uint256) { return endId - currentIndex + 1; } function getContractBalance() external view onlyAdmin returns (uint256) { return address(this).balance; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
// 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); }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "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":"_nftContract","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_startId","type":"uint256"},{"internalType":"uint256","name":"_endId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"PriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Purchase","type":"event"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getContractBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRemainingNFTs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"purchase","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"updatePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162000c3e38038062000c3e83398181016040528101906200003791906200017c565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600281905550816003819055508060048190555050505050620001ee565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200010982620000dc565b9050919050565b6200011b81620000fc565b81146200012757600080fd5b50565b6000815190506200013b8162000110565b92915050565b6000819050919050565b620001568162000141565b81146200016257600080fd5b50565b60008151905062000176816200014b565b92915050565b60008060008060808587031215620001995762000198620000d7565b5b6000620001a9878288016200012a565b9450506020620001bc8782880162000165565b9350506040620001cf8782880162000165565b9250506060620001e28782880162000165565b91505092959194509250565b610a4080620001fe6000396000f3fe6080604052600436106100915760003560e01c806377df012e1161005957806377df012e146101385780638d6cc56d14610163578063a035b1fe1461018c578063d56d229d146101b7578063f851a440146101e257610091565b8063238c67211461009657806326987b60146100c15780633ccfd60b146100ec57806364edfbf0146101035780636f9fb98a1461010d575b600080fd5b3480156100a257600080fd5b506100ab61020d565b6040516100b891906106a4565b60405180910390f35b3480156100cd57600080fd5b506100d6610230565b6040516100e391906106a4565b60405180910390f35b3480156100f857600080fd5b50610101610236565b005b61010b61032d565b005b34801561011957600080fd5b506101226104cf565b60405161012f91906106a4565b60405180910390f35b34801561014457600080fd5b5061014d610566565b60405161015a91906106a4565b60405180910390f35b34801561016f57600080fd5b5061018a600480360381019061018591906106f0565b61056c565b005b34801561019857600080fd5b506101a161063b565b6040516101ae91906106a4565b60405180910390f35b3480156101c357600080fd5b506101cc610641565b6040516101d9919061075e565b60405180910390f35b3480156101ee57600080fd5b506101f7610667565b604051610204919061075e565b60405180910390f35b6000600160035460045461022191906107a8565b61022b91906107dc565b905090565b60035481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102bb90610893565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561032a573d6000803e3d6000fd5b50565b6004546003541115610374576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036b906108ff565b60405180910390fd5b60025434146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061096b565b60405180910390fd5b60006003549050600360008154809291906103d29061098b565b9190505550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633846040518463ffffffff1660e01b8152600401610456939291906109d3565b600060405180830381600087803b15801561047057600080fd5b505af1158015610484573d6000803e3d6000fd5b50505050803373ffffffffffffffffffffffffffffffffffffffff167f2499a5330ab0979cc612135e7883ebc3cd5c9f7a8508f042540c34723348f63260405160405180910390a350565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055790610893565b60405180910390fd5b47905090565b60045481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f190610893565b60405180910390fd5b806002819055507f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe08160405161063091906106a4565b60405180910390a150565b60025481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61069e8161068b565b82525050565b60006020820190506106b96000830184610695565b92915050565b600080fd5b6106cd8161068b565b81146106d857600080fd5b50565b6000813590506106ea816106c4565b92915050565b600060208284031215610706576107056106bf565b5b6000610714848285016106db565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107488261071d565b9050919050565b6107588161073d565b82525050565b6000602082019050610773600083018461074f565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107b38261068b565b91506107be8361068b565b92508282039050818111156107d6576107d5610779565b5b92915050565b60006107e78261068b565b91506107f28361068b565b925082820190508082111561080a57610809610779565b5b92915050565b600082825260208201905092915050565b7f4f6e6c792061646d696e2063616e20706572666f726d2074686973206163746960008201527f6f6e000000000000000000000000000000000000000000000000000000000000602082015250565b600061087d602283610810565b915061088882610821565b604082019050919050565b600060208201905081810360008301526108ac81610870565b9050919050565b7f416c6c204e46547320736f6c64206f7574000000000000000000000000000000600082015250565b60006108e9601183610810565b91506108f4826108b3565b602082019050919050565b60006020820190508181036000830152610918816108dc565b9050919050565b7f496e636f7272656374207061796d656e7420616d6f756e740000000000000000600082015250565b6000610955601883610810565b91506109608261091f565b602082019050919050565b6000602082019050818103600083015261098481610948565b9050919050565b60006109968261068b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036109c8576109c7610779565b5b600182019050919050565b60006060820190506109e8600083018661074f565b6109f5602083018561074f565b610a026040830184610695565b94935050505056fea2646970667358221220e6c743e61fd4a6b270935843cbb94799514ebc588b591a9f3eb49b87086b635464736f6c634300081500330000000000000000000000003bc555f23141e6e4edffad999a71ecfecc44c3fe000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000009
Deployed Bytecode
0x6080604052600436106100915760003560e01c806377df012e1161005957806377df012e146101385780638d6cc56d14610163578063a035b1fe1461018c578063d56d229d146101b7578063f851a440146101e257610091565b8063238c67211461009657806326987b60146100c15780633ccfd60b146100ec57806364edfbf0146101035780636f9fb98a1461010d575b600080fd5b3480156100a257600080fd5b506100ab61020d565b6040516100b891906106a4565b60405180910390f35b3480156100cd57600080fd5b506100d6610230565b6040516100e391906106a4565b60405180910390f35b3480156100f857600080fd5b50610101610236565b005b61010b61032d565b005b34801561011957600080fd5b506101226104cf565b60405161012f91906106a4565b60405180910390f35b34801561014457600080fd5b5061014d610566565b60405161015a91906106a4565b60405180910390f35b34801561016f57600080fd5b5061018a600480360381019061018591906106f0565b61056c565b005b34801561019857600080fd5b506101a161063b565b6040516101ae91906106a4565b60405180910390f35b3480156101c357600080fd5b506101cc610641565b6040516101d9919061075e565b60405180910390f35b3480156101ee57600080fd5b506101f7610667565b604051610204919061075e565b60405180910390f35b6000600160035460045461022191906107a8565b61022b91906107dc565b905090565b60035481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102bb90610893565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561032a573d6000803e3d6000fd5b50565b6004546003541115610374576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036b906108ff565b60405180910390fd5b60025434146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061096b565b60405180910390fd5b60006003549050600360008154809291906103d29061098b565b9190505550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633846040518463ffffffff1660e01b8152600401610456939291906109d3565b600060405180830381600087803b15801561047057600080fd5b505af1158015610484573d6000803e3d6000fd5b50505050803373ffffffffffffffffffffffffffffffffffffffff167f2499a5330ab0979cc612135e7883ebc3cd5c9f7a8508f042540c34723348f63260405160405180910390a350565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055790610893565b60405180910390fd5b47905090565b60045481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f190610893565b60405180910390fd5b806002819055507f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe08160405161063091906106a4565b60405180910390a150565b60025481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61069e8161068b565b82525050565b60006020820190506106b96000830184610695565b92915050565b600080fd5b6106cd8161068b565b81146106d857600080fd5b50565b6000813590506106ea816106c4565b92915050565b600060208284031215610706576107056106bf565b5b6000610714848285016106db565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107488261071d565b9050919050565b6107588161073d565b82525050565b6000602082019050610773600083018461074f565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107b38261068b565b91506107be8361068b565b92508282039050818111156107d6576107d5610779565b5b92915050565b60006107e78261068b565b91506107f28361068b565b925082820190508082111561080a57610809610779565b5b92915050565b600082825260208201905092915050565b7f4f6e6c792061646d696e2063616e20706572666f726d2074686973206163746960008201527f6f6e000000000000000000000000000000000000000000000000000000000000602082015250565b600061087d602283610810565b915061088882610821565b604082019050919050565b600060208201905081810360008301526108ac81610870565b9050919050565b7f416c6c204e46547320736f6c64206f7574000000000000000000000000000000600082015250565b60006108e9601183610810565b91506108f4826108b3565b602082019050919050565b60006020820190508181036000830152610918816108dc565b9050919050565b7f496e636f7272656374207061796d656e7420616d6f756e740000000000000000600082015250565b6000610955601883610810565b91506109608261091f565b602082019050919050565b6000602082019050818103600083015261098481610948565b9050919050565b60006109968261068b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036109c8576109c7610779565b5b600182019050919050565b60006060820190506109e8600083018661074f565b6109f5602083018561074f565b610a026040830184610695565b94935050505056fea2646970667358221220e6c743e61fd4a6b270935843cbb94799514ebc588b591a9f3eb49b87086b635464736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003bc555f23141e6e4edffad999a71ecfecc44c3fe000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000009
-----Decoded View---------------
Arg [0] : _nftContract (address): 0x3bc555F23141e6E4eDFfaD999A71ecfEcC44c3FE
Arg [1] : _price (uint256): 100000000000000000
Arg [2] : _startId (uint256): 3
Arg [3] : _endId (uint256): 9
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000003bc555f23141e6e4edffad999a71ecfecc44c3fe
Arg [1] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000009
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ 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.