Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
MyToken
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
No with 200 runs
Other Settings:
default 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 MyToken{ IERC721 public nftContract; // NFT合约地址 constructor(address _nftAddress) { nftContract = IERC721(_nftAddress); } // 用户授权合约操作NFT function authorizeNFT(uint256 _tokenId) public { nftContract.approve(address(this), _tokenId); } // 将NFT转移到合约中 function transferNFTToContract(address _owner, uint256 _tokenId) public { nftContract.transferFrom(_owner, address(this), _tokenId); } // 将NFT从合约转移到另一个地址 function transferNFTFromContract(address _to, uint256 _tokenId) public { nftContract.transferFrom(address(this), _to, _tokenId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-721 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 ERC-721 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 ERC-721 * 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 address zero. * * 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 (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * 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[ERC 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); }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "remappings": [] }
[{"inputs":[{"internalType":"address","name":"_nftAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"authorizeNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferNFTFromContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferNFTToContract","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561000f575f80fd5b506040516105b13803806105b1833981810160405281019061003191906100d4565b805f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506100ff565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a38261007a565b9050919050565b6100b381610099565b81146100bd575f80fd5b50565b5f815190506100ce816100aa565b92915050565b5f602082840312156100e9576100e8610076565b5b5f6100f6848285016100c0565b91505092915050565b6104a58061010c5f395ff3fe608060405234801561000f575f80fd5b506004361061004a575f3560e01c80632c3464e81461004e578063782ad4221461006a578063a90dceab14610086578063d56d229d146100a2575b5f80fd5b61006860048036038101906100639190610318565b6100c0565b005b610084600480360381019061007f9190610356565b61014d565b005b6100a0600480360381019061009b9190610318565b6101d7565b005b6100aa610264565b6040516100b791906103dc565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b815260040161011c93929190610413565b5f604051808303815f87803b158015610133575f80fd5b505af1158015610145573d5f803e3d5ffd5b505050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b81526004016101a7929190610448565b5f604051808303815f87803b1580156101be575f80fd5b505af11580156101d0573d5f803e3d5ffd5b5050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd8330846040518463ffffffff1660e01b815260040161023393929190610413565b5f604051808303815f87803b15801561024a575f80fd5b505af115801561025c573d5f803e3d5ffd5b505050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102b48261028b565b9050919050565b6102c4816102aa565b81146102ce575f80fd5b50565b5f813590506102df816102bb565b92915050565b5f819050919050565b6102f7816102e5565b8114610301575f80fd5b50565b5f81359050610312816102ee565b92915050565b5f806040838503121561032e5761032d610287565b5b5f61033b858286016102d1565b925050602061034c85828601610304565b9150509250929050565b5f6020828403121561036b5761036a610287565b5b5f61037884828501610304565b91505092915050565b5f819050919050565b5f6103a461039f61039a8461028b565b610381565b61028b565b9050919050565b5f6103b58261038a565b9050919050565b5f6103c6826103ab565b9050919050565b6103d6816103bc565b82525050565b5f6020820190506103ef5f8301846103cd565b92915050565b6103fe816102aa565b82525050565b61040d816102e5565b82525050565b5f6060820190506104265f8301866103f5565b61043360208301856103f5565b6104406040830184610404565b949350505050565b5f60408201905061045b5f8301856103f5565b6104686020830184610404565b939250505056fea26469706673582212209bdd8132a5c746ae65dc07e81fa42551d5f7804ebf33638df6d0b424f938a14e64736f6c6343000814003300000000000000000000000043c651e840d56ee0b00ad287748d79b06cf63571
Deployed Bytecode
0x608060405234801561000f575f80fd5b506004361061004a575f3560e01c80632c3464e81461004e578063782ad4221461006a578063a90dceab14610086578063d56d229d146100a2575b5f80fd5b61006860048036038101906100639190610318565b6100c0565b005b610084600480360381019061007f9190610356565b61014d565b005b6100a0600480360381019061009b9190610318565b6101d7565b005b6100aa610264565b6040516100b791906103dc565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b815260040161011c93929190610413565b5f604051808303815f87803b158015610133575f80fd5b505af1158015610145573d5f803e3d5ffd5b505050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b81526004016101a7929190610448565b5f604051808303815f87803b1580156101be575f80fd5b505af11580156101d0573d5f803e3d5ffd5b5050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd8330846040518463ffffffff1660e01b815260040161023393929190610413565b5f604051808303815f87803b15801561024a575f80fd5b505af115801561025c573d5f803e3d5ffd5b505050505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102b48261028b565b9050919050565b6102c4816102aa565b81146102ce575f80fd5b50565b5f813590506102df816102bb565b92915050565b5f819050919050565b6102f7816102e5565b8114610301575f80fd5b50565b5f81359050610312816102ee565b92915050565b5f806040838503121561032e5761032d610287565b5b5f61033b858286016102d1565b925050602061034c85828601610304565b9150509250929050565b5f6020828403121561036b5761036a610287565b5b5f61037884828501610304565b91505092915050565b5f819050919050565b5f6103a461039f61039a8461028b565b610381565b61028b565b9050919050565b5f6103b58261038a565b9050919050565b5f6103c6826103ab565b9050919050565b6103d6816103bc565b82525050565b5f6020820190506103ef5f8301846103cd565b92915050565b6103fe816102aa565b82525050565b61040d816102e5565b82525050565b5f6060820190506104265f8301866103f5565b61043360208301856103f5565b6104406040830184610404565b949350505050565b5f60408201905061045b5f8301856103f5565b6104686020830184610404565b939250505056fea26469706673582212209bdd8132a5c746ae65dc07e81fa42551d5f7804ebf33638df6d0b424f938a14e64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000043c651e840d56ee0b00ad287748d79b06cf63571
-----Decoded View---------------
Arg [0] : _nftAddress (address): 0x43C651e840D56eE0B00AD287748D79B06Cf63571
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000043c651e840d56ee0b00ad287748d79b06cf63571
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.