APE Price: $0.99 (-0.05%)

Contract

0x48712624dc45a8aae41b933b36834013F9292185

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x7ad2F6DF...873C5b9FB
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
NFTMarketplace

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
No with 200 runs

Other Settings:
paris EvmVersion
File 1 of 3 : NFTMarketplace.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract NFTMarketplace {
    struct Listing {
        address seller;
        uint256 price;
    }

    // 存储每个NFT的上架信息
    mapping(uint256 => Listing) public listings;

    // NFT合约地址
    IERC721 public nftContract;

    // 市场事件
    event ItemListed(
        address indexed seller,
        uint256 indexed tokenId,
        uint256 price
    );
    event ItemDelisted(address indexed seller, uint256 indexed tokenId);
    event ItemPurchased(
        address indexed buyer,
        address indexed seller,
        uint256 indexed tokenId,
        uint256 price
    );

    constructor(address _nftContract) {
        require(_nftContract != address(0), "Invalid NFT contract address");
        nftContract = IERC721(_nftContract);
    }

    // 上架NFT
    function listItem(uint256 tokenId, uint256 price) external {
        require(price > 0, "Price must be greater than zero");
        require(
            nftContract.ownerOf(tokenId) == msg.sender,
            "You are not the owner"
        );
        require(
            nftContract.getApproved(tokenId) == address(this) ||
                nftContract.isApprovedForAll(msg.sender, address(this)),
            "Marketplace not approved"
        );

        listings[tokenId] = Listing(msg.sender, price);

        emit ItemListed(msg.sender, tokenId, price);
    }

    // 下架NFT
    function delistItem(uint256 tokenId) external {
        Listing memory listing = listings[tokenId];
        require(listing.seller == msg.sender, "You are not the seller");

        delete listings[tokenId];

        emit ItemDelisted(msg.sender, tokenId);
    }

    // 购买NFT
    function buyItem(uint256 tokenId) external payable {
        Listing memory listing = listings[tokenId];
        require(listing.price > 0, "Item not listed");
        require(msg.value == listing.price, "Incorrect payment amount");

        // 转账给卖家
        payable(listing.seller).transfer(msg.value);

        // 转移NFT到买家
        nftContract.safeTransferFrom(listing.seller, msg.sender, tokenId);

        // 从列表中移除
        delete listings[tokenId];

        emit ItemPurchased(msg.sender, listing.seller, tokenId, msg.value);
    }

    // 获取NFT的上架信息
    function getListing(
        uint256 tokenId
    ) external view returns (Listing memory) {
        return listings[tokenId];
    }
}

File 2 of 3 : IERC721.sol
// 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);
}

File 3 of 3 : IERC165.sol
// 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);
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ItemDelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"ItemListed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"ItemPurchased","type":"event"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"buyItem","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"delistItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getListing","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct NFTMarketplace.Listing","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"listItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"listings","outputs":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x6080604052600436106100555760003560e01c8063100616311461005a578063107a274a14610083578063883efa67146100c0578063d56d229d146100e9578063de74e57b14610114578063e7fb74c714610152575b600080fd5b34801561006657600080fd5b50610081600480360381019061007c9190610acc565b61016e565b005b34801561008f57600080fd5b506100aa60048036038101906100a59190610acc565b6102ed565b6040516100b79190610b78565b60405180910390f35b3480156100cc57600080fd5b506100e760048036038101906100e29190610b93565b610379565b005b3480156100f557600080fd5b506100fe610757565b60405161010b9190610c32565b60405180910390f35b34801561012057600080fd5b5061013b60048036038101906101369190610acc565b61077d565b604051610149929190610c6b565b60405180910390f35b61016c60048036038101906101679190610acc565b6107c1565b005b60008060008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152505090503373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610261576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025890610cf1565b60405180910390fd5b600080838152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560018201600090555050813373ffffffffffffffffffffffffffffffffffffffff167faca2f4260fb2b4e6aa5f68a07c66e0a461f508267354a97bbefb46e09c9b875d60405160405180910390a35050565b6102f5610a61565b6000808381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815250509050919050565b600081116103bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103b390610d5d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e846040518263ffffffff1660e01b815260040161042e9190610d7d565b602060405180830381865afa15801561044b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046f9190610dc4565b73ffffffffffffffffffffffffffffffffffffffff16146104c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104bc90610e3d565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663081812fc846040518263ffffffff1660e01b81526004016105379190610d7d565b602060405180830381865afa158015610554573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105789190610dc4565b73ffffffffffffffffffffffffffffffffffffffff1614806106345750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e985e9c533306040518363ffffffff1660e01b81526004016105f2929190610e5d565b602060405180830381865afa15801561060f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106339190610ebe565b5b610673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066a90610f37565b60405180910390fd5b60405180604001604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018281525060008084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155905050813373ffffffffffffffffffffffffffffffffffffffff167f94e7b934c857a9e3202e8ed9c1f3f96e396b7d2b5885930d2001abcb51ff58fa8360405161074b9190610d7d565b60405180910390a35050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b60008060008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152505090506000816020015111610889576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088090610fa3565b60405180910390fd5b806020015134146108cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c69061100f565b60405180910390fd5b806000015173ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610919573d6000803e3d6000fd5b50600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e826000015133856040518463ffffffff1660e01b815260040161097d9392919061102f565b600060405180830381600087803b15801561099757600080fd5b505af11580156109ab573d6000803e3d6000fd5b50505050600080838152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160009055505081816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f53d5014fa27fa078ecec13b4311f8520b2192980af8b38cf8e870ed26576046434604051610a559190610d7d565b60405180910390a45050565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b600080fd5b6000819050919050565b610aa981610a96565b8114610ab457600080fd5b50565b600081359050610ac681610aa0565b92915050565b600060208284031215610ae257610ae1610a91565b5b6000610af084828501610ab7565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b2482610af9565b9050919050565b610b3481610b19565b82525050565b610b4381610a96565b82525050565b604082016000820151610b5f6000850182610b2b565b506020820151610b726020850182610b3a565b50505050565b6000604082019050610b8d6000830184610b49565b92915050565b60008060408385031215610baa57610ba9610a91565b5b6000610bb885828601610ab7565b9250506020610bc985828601610ab7565b9150509250929050565b6000819050919050565b6000610bf8610bf3610bee84610af9565b610bd3565b610af9565b9050919050565b6000610c0a82610bdd565b9050919050565b6000610c1c82610bff565b9050919050565b610c2c81610c11565b82525050565b6000602082019050610c476000830184610c23565b92915050565b610c5681610b19565b82525050565b610c6581610a96565b82525050565b6000604082019050610c806000830185610c4d565b610c8d6020830184610c5c565b9392505050565b600082825260208201905092915050565b7f596f7520617265206e6f74207468652073656c6c657200000000000000000000600082015250565b6000610cdb601683610c94565b9150610ce682610ca5565b602082019050919050565b60006020820190508181036000830152610d0a81610cce565b9050919050565b7f5072696365206d7573742062652067726561746572207468616e207a65726f00600082015250565b6000610d47601f83610c94565b9150610d5282610d11565b602082019050919050565b60006020820190508181036000830152610d7681610d3a565b9050919050565b6000602082019050610d926000830184610c5c565b92915050565b610da181610b19565b8114610dac57600080fd5b50565b600081519050610dbe81610d98565b92915050565b600060208284031215610dda57610dd9610a91565b5b6000610de884828501610daf565b91505092915050565b7f596f7520617265206e6f7420746865206f776e65720000000000000000000000600082015250565b6000610e27601583610c94565b9150610e3282610df1565b602082019050919050565b60006020820190508181036000830152610e5681610e1a565b9050919050565b6000604082019050610e726000830185610c4d565b610e7f6020830184610c4d565b9392505050565b60008115159050919050565b610e9b81610e86565b8114610ea657600080fd5b50565b600081519050610eb881610e92565b92915050565b600060208284031215610ed457610ed3610a91565b5b6000610ee284828501610ea9565b91505092915050565b7f4d61726b6574706c616365206e6f7420617070726f7665640000000000000000600082015250565b6000610f21601883610c94565b9150610f2c82610eeb565b602082019050919050565b60006020820190508181036000830152610f5081610f14565b9050919050565b7f4974656d206e6f74206c69737465640000000000000000000000000000000000600082015250565b6000610f8d600f83610c94565b9150610f9882610f57565b602082019050919050565b60006020820190508181036000830152610fbc81610f80565b9050919050565b7f496e636f7272656374207061796d656e7420616d6f756e740000000000000000600082015250565b6000610ff9601883610c94565b915061100482610fc3565b602082019050919050565b6000602082019050818103600083015261102881610fec565b9050919050565b60006060820190506110446000830186610c4d565b6110516020830185610c4d565b61105e6040830184610c5c565b94935050505056fea264697066735822122026ea7dee3aa302faabb66592e6576e94a67686b6f19b54332bb7dbea77af6f7a64736f6c63430008140033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.