Overview
APE Balance
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
BatchTransfer
Compiler Version
v0.8.27+commit.40a35a09
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Import the IERC721 interface from OpenZeppelin import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; contract BatchTransfer { address public nftContractAddress; // Constructor to initialize the NFT contract address constructor(address _nftContractAddress) { nftContractAddress = _nftContractAddress; } // Internal function to check and set approval for all tokens function setApprovalIfNeeded() internal { IERC721 nftContract = IERC721(nftContractAddress); // Check if the contract has approval to transfer tokens on behalf of the user bool isApproved = nftContract.isApprovedForAll(msg.sender, address(this)); // If not approved, set approval if (!isApproved) { nftContract.setApprovalForAll(address(this), true); } } // Batch transfer function function batchTransfer(address[] calldata to, uint256[] calldata tokenIds) external { require(to.length == tokenIds.length, "Arrays must be the same length"); // First, ensure approval is granted to the contract setApprovalIfNeeded(); IERC721 nftContract = IERC721(nftContractAddress); // Loop through all tokens and perform transfers for (uint256 i = 0; i < tokenIds.length; i++) { address tokenOwner = nftContract.ownerOf(tokenIds[i]); require(tokenOwner == msg.sender, "You do not own this token"); // Transfer each token from the sender to the recipient nftContract.transferFrom(msg.sender, to[i], tokenIds[i]); } } }
// 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": true, "runs": 200 }, "evmVersion": "paris", "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":"_nftContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"batchTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6080604052348015600f57600080fd5b50604051610590380380610590833981016040819052602c916050565b600080546001600160a01b0319166001600160a01b0392909216919091179055607e565b600060208284031215606157600080fd5b81516001600160a01b0381168114607757600080fd5b9392505050565b6105038061008d6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806388d695b21461003b578063aae282e114610050575b600080fd5b61004e6100493660046103cb565b61007f565b005b600054610063906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b8281146100d35760405162461bcd60e51b815260206004820152601e60248201527f417272617973206d757374206265207468652073616d65206c656e677468000060448201526064015b60405180910390fd5b6100db6102a2565b600080546001600160a01b0316905b8281101561029a576000826001600160a01b0316636352211e8686858181106101155761011561043c565b905060200201356040518263ffffffff1660e01b815260040161013a91815260200190565b602060405180830381865afa158015610157573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017b919061046a565b90506001600160a01b03811633146101d55760405162461bcd60e51b815260206004820152601960248201527f596f7520646f206e6f74206f776e207468697320746f6b656e0000000000000060448201526064016100ca565b826001600160a01b03166323b872dd338989868181106101f7576101f761043c565b905060200201602081019061020c919061048e565b88888781811061021e5761021e61043c565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b15801561027557600080fd5b505af1158015610289573d6000803e3d6000fd5b5050600190930192506100ea915050565b505050505050565b6000805460405163e985e9c560e01b81523360048201523060248201526001600160a01b039091169190829063e985e9c590604401602060405180830381865afa1580156102f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031891906104ab565b90508061037b5760405163a22cb46560e01b8152306004820152600160248201526001600160a01b0383169063a22cb46590604401600060405180830381600087803b15801561036757600080fd5b505af115801561029a573d6000803e3d6000fd5b5050565b60008083601f84011261039157600080fd5b50813567ffffffffffffffff8111156103a957600080fd5b6020830191508360208260051b85010111156103c457600080fd5b9250929050565b600080600080604085870312156103e157600080fd5b843567ffffffffffffffff8111156103f857600080fd5b6104048782880161037f565b909550935050602085013567ffffffffffffffff81111561042457600080fd5b6104308782880161037f565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461046757600080fd5b50565b60006020828403121561047c57600080fd5b815161048781610452565b9392505050565b6000602082840312156104a057600080fd5b813561048781610452565b6000602082840312156104bd57600080fd5b8151801515811461048757600080fdfea2646970667358221220ebb70fc1d59cc0a2a7241eff685d9b2df796a9e2f6457c9ea36fd0276f2c043464736f6c634300081b003300000000000000000000000022526ada48dd610fb48e7f8b7b496b597c043fc4
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c806388d695b21461003b578063aae282e114610050575b600080fd5b61004e6100493660046103cb565b61007f565b005b600054610063906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b8281146100d35760405162461bcd60e51b815260206004820152601e60248201527f417272617973206d757374206265207468652073616d65206c656e677468000060448201526064015b60405180910390fd5b6100db6102a2565b600080546001600160a01b0316905b8281101561029a576000826001600160a01b0316636352211e8686858181106101155761011561043c565b905060200201356040518263ffffffff1660e01b815260040161013a91815260200190565b602060405180830381865afa158015610157573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017b919061046a565b90506001600160a01b03811633146101d55760405162461bcd60e51b815260206004820152601960248201527f596f7520646f206e6f74206f776e207468697320746f6b656e0000000000000060448201526064016100ca565b826001600160a01b03166323b872dd338989868181106101f7576101f761043c565b905060200201602081019061020c919061048e565b88888781811061021e5761021e61043c565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b15801561027557600080fd5b505af1158015610289573d6000803e3d6000fd5b5050600190930192506100ea915050565b505050505050565b6000805460405163e985e9c560e01b81523360048201523060248201526001600160a01b039091169190829063e985e9c590604401602060405180830381865afa1580156102f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031891906104ab565b90508061037b5760405163a22cb46560e01b8152306004820152600160248201526001600160a01b0383169063a22cb46590604401600060405180830381600087803b15801561036757600080fd5b505af115801561029a573d6000803e3d6000fd5b5050565b60008083601f84011261039157600080fd5b50813567ffffffffffffffff8111156103a957600080fd5b6020830191508360208260051b85010111156103c457600080fd5b9250929050565b600080600080604085870312156103e157600080fd5b843567ffffffffffffffff8111156103f857600080fd5b6104048782880161037f565b909550935050602085013567ffffffffffffffff81111561042457600080fd5b6104308782880161037f565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461046757600080fd5b50565b60006020828403121561047c57600080fd5b815161048781610452565b9392505050565b6000602082840312156104a057600080fd5b813561048781610452565b6000602082840312156104bd57600080fd5b8151801515811461048757600080fdfea2646970667358221220ebb70fc1d59cc0a2a7241eff685d9b2df796a9e2f6457c9ea36fd0276f2c043464736f6c634300081b0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000022526ada48dd610fb48e7f8b7b496b597c043fc4
-----Decoded View---------------
Arg [0] : _nftContractAddress (address): 0x22526aDa48Dd610Fb48E7f8b7B496b597C043fC4
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000022526ada48dd610fb48e7f8b7b496b597c043fc4
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.