Discover more of Apescan's tools and services in one place.
Contract Source Code:
File 1 of 1 : Test.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC721 { function setApprovalForAll(address operator, bool approved) external; function safeTransferFrom(address from, address to, uint256 tokenId) external; function isApprovedForAll(address owner, address operator) external view returns (bool); } contract BatchTransfer { address public nftContract; // Constructor to set the NFT contract address constructor(address _nftContract) { nftContract = _nftContract; } // Function for the owner to set approval for the batch transfer contract on the NFT contract function approveBatchTransferContract() external { IERC721(nftContract).setApprovalForAll(address(this), true); } // Function to batch transfer ERC721 tokens from a single owner to a recipient function batchTransfer( address from, address to, uint256[] calldata tokenIds ) external { require(tokenIds.length > 0, "No tokens provided for transfer"); // Ensure that the contract is approved to transfer tokens require(IERC721(nftContract).isApprovedForAll(from, address(this)), "Contract not approved for transfer"); for (uint256 i = 0; i < tokenIds.length; i++) { IERC721(nftContract).safeTransferFrom(from, to, tokenIds[i]); } } }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.