APE Price: $1.16 (+3.63%)

Contract

0x81843586d6283E3e54Ef3171b715eBc06d75aFBA

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Approve Contract...41807582024-11-12 22:33:199 days ago1731450799IN
0x81843586...06d75aFBA
0 APE0.0015687625.42069
0x6080604041807292024-11-12 22:32:239 days ago1731450743IN
 Create: BatchTransfer
0 APE0.0091218825.42069

Parent Transaction Hash Block From To
View All Internal Transactions

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

    // Function to approve the contract to transfer tokens on behalf of the user
    function approveContractForTransfers() external {
        IERC721 nftContract = IERC721(nftContractAddress);
        bool isApproved = nftContract.isApprovedForAll(msg.sender, address(this));

        // If not approved, set approval
        if (!isApproved) {
            nftContract.setApprovalForAll(address(this), true);
        }
    }

    // Internal function to check and set approval for all tokens (called within batch transfer)
    function setApprovalIfNeeded() internal {
        IERC721 nftContract = IERC721(nftContractAddress);
        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]);
        }
    }
}

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"approveContractForTransfers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"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"}]

6080604052348015600f57600080fd5b506040516105a33803806105a3833981016040819052602c916050565b600080546001600160a01b0319166001600160a01b0392909216919091179055607e565b600060208284031215606157600080fd5b81516001600160a01b0381168114607757600080fd5b9392505050565b6105168061008d6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806388d695b214610046578063aae282e11461005b578063fb9749011461008a575b600080fd5b6100596100543660046103de565b610092565b005b60005461006e906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100596102b5565b8281146100e65760405162461bcd60e51b815260206004820152601e60248201527f417272617973206d757374206265207468652073616d65206c656e677468000060448201526064015b60405180910390fd5b6100ee6102b5565b600080546001600160a01b0316905b828110156102ad576000826001600160a01b0316636352211e8686858181106101285761012861044f565b905060200201356040518263ffffffff1660e01b815260040161014d91815260200190565b602060405180830381865afa15801561016a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018e919061047d565b90506001600160a01b03811633146101e85760405162461bcd60e51b815260206004820152601960248201527f596f7520646f206e6f74206f776e207468697320746f6b656e0000000000000060448201526064016100dd565b826001600160a01b03166323b872dd3389898681811061020a5761020a61044f565b905060200201602081019061021f91906104a1565b8888878181106102315761023161044f565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b15801561028857600080fd5b505af115801561029c573d6000803e3d6000fd5b5050600190930192506100fd915050565b505050505050565b6000805460405163e985e9c560e01b81523360048201523060248201526001600160a01b039091169190829063e985e9c590604401602060405180830381865afa158015610307573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061032b91906104be565b90508061038e5760405163a22cb46560e01b8152306004820152600160248201526001600160a01b0383169063a22cb46590604401600060405180830381600087803b15801561037a57600080fd5b505af11580156102ad573d6000803e3d6000fd5b5050565b60008083601f8401126103a457600080fd5b50813567ffffffffffffffff8111156103bc57600080fd5b6020830191508360208260051b85010111156103d757600080fd5b9250929050565b600080600080604085870312156103f457600080fd5b843567ffffffffffffffff81111561040b57600080fd5b61041787828801610392565b909550935050602085013567ffffffffffffffff81111561043757600080fd5b61044387828801610392565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461047a57600080fd5b50565b60006020828403121561048f57600080fd5b815161049a81610465565b9392505050565b6000602082840312156104b357600080fd5b813561049a81610465565b6000602082840312156104d057600080fd5b8151801515811461049a57600080fdfea26469706673582212203c2e31c599cbc1c535ec693bac3accc6597dfc40ad107492e8998e7d5c95af0464736f6c634300081b003300000000000000000000000022526ada48dd610fb48e7f8b7b496b597c043fc4

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100415760003560e01c806388d695b214610046578063aae282e11461005b578063fb9749011461008a575b600080fd5b6100596100543660046103de565b610092565b005b60005461006e906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100596102b5565b8281146100e65760405162461bcd60e51b815260206004820152601e60248201527f417272617973206d757374206265207468652073616d65206c656e677468000060448201526064015b60405180910390fd5b6100ee6102b5565b600080546001600160a01b0316905b828110156102ad576000826001600160a01b0316636352211e8686858181106101285761012861044f565b905060200201356040518263ffffffff1660e01b815260040161014d91815260200190565b602060405180830381865afa15801561016a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018e919061047d565b90506001600160a01b03811633146101e85760405162461bcd60e51b815260206004820152601960248201527f596f7520646f206e6f74206f776e207468697320746f6b656e0000000000000060448201526064016100dd565b826001600160a01b03166323b872dd3389898681811061020a5761020a61044f565b905060200201602081019061021f91906104a1565b8888878181106102315761023161044f565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b15801561028857600080fd5b505af115801561029c573d6000803e3d6000fd5b5050600190930192506100fd915050565b505050505050565b6000805460405163e985e9c560e01b81523360048201523060248201526001600160a01b039091169190829063e985e9c590604401602060405180830381865afa158015610307573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061032b91906104be565b90508061038e5760405163a22cb46560e01b8152306004820152600160248201526001600160a01b0383169063a22cb46590604401600060405180830381600087803b15801561037a57600080fd5b505af11580156102ad573d6000803e3d6000fd5b5050565b60008083601f8401126103a457600080fd5b50813567ffffffffffffffff8111156103bc57600080fd5b6020830191508360208260051b85010111156103d757600080fd5b9250929050565b600080600080604085870312156103f457600080fd5b843567ffffffffffffffff81111561040b57600080fd5b61041787828801610392565b909550935050602085013567ffffffffffffffff81111561043757600080fd5b61044387828801610392565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461047a57600080fd5b50565b60006020828403121561048f57600080fd5b815161049a81610465565b9392505050565b6000602082840312156104b357600080fd5b813561049a81610465565b6000602082840312156104d057600080fd5b8151801515811461049a57600080fdfea26469706673582212203c2e31c599cbc1c535ec693bac3accc6597dfc40ad107492e8998e7d5c95af0464736f6c634300081b0033

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


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
[ 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.