false
true
0

Contract Address Details

0x3b07B2bb728D0bF1271C19c22A997D8407E9AA95

Contract Name
ERC721Adapter
Creator
0x7a9066–4cc6eb at 0x06c9ce–b8ea07
Balance
0 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
25349486
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
ERC721Adapter




Optimization enabled
true
Compiler version
v0.8.23+commit.f704f362




Optimization runs
999999
EVM Version
paris




Verified at
2024-04-16T10:29:25.877134Z

contracts/adapters/ERC721Adapter.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.23;

import "../interfaces/IAdapter.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract ERC721Adapter is IAdapter {
  /**
   * @notice Indicates the ERC165 interfaceId supported by this adapter
   */
  bytes4 public constant interfaceId = 0x80ac58cd;

  /**
   * @notice Checks allowance on an ERC721
   * @param party Party params to check
   * @dev Use call: "msg.sender" is Swap contract
   */
  function hasAllowance(Party calldata party) external view returns (bool) {
    return IERC721(party.token).getApproved(party.id) == address(msg.sender);
  }

  /**
   * @notice Checks balance on an ERC721
   * @param party Party params to check
   */
  function hasBalance(Party calldata party) external view returns (bool) {
    return IERC721(party.token).ownerOf(party.id) == party.wallet;
  }

  /**
   * @notice Checks params for transfer
   * @param party Party params to check
   */
  function hasValidParams(Party calldata party) external pure returns (bool) {
    return (party.amount == 0);
  }

  /**
   * @notice Function to wrap safeTransferFrom for ERC721
   * @param from address Wallet address to transfer from
   * @param to address Wallet address to transfer to
   * @param amount uint256, must be 0 for this contract
   * @param id uint256 ID for ERC721
   * @param token address Contract address of token
   * @dev Use delegatecall: "this" is Swap contract
   */
  function transfer(
    address from,
    address to,
    uint256 amount,
    uint256 id,
    address token
  ) external {
    if (amount != 0) revert AmountOrIDInvalid("amount");
    IERC721(token).safeTransferFrom(from, to, id);
  }
}
        

@openzeppelin/contracts/token/ERC721/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);
}
          

@openzeppelin/contracts/utils/introspection/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);
}
          

contracts/interfaces/IAdapter.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.23;

struct Party {
  address wallet; // Wallet address of the party
  address token; // Contract address of the token
  bytes4 kind; // Interface ID of the token
  uint256 id; // ID for ERC-721 or ERC-1155
  uint256 amount; // Amount for ERC-20 or ERC-1155
}

/**
 * @title IAdapter: Adapter for various token kinds
 */
interface IAdapter {
  /**
   * @notice Revert if provided an invalid transfer argument
   */
  error AmountOrIDInvalid(string);

  /**
   * @notice Return the ERC165 interfaceId this adapter supports
   */
  function interfaceId() external view returns (bytes4);

  /**
   * @notice Checks allowance on a token
   * @param party Party params to check
   */
  function hasAllowance(Party calldata party) external view returns (bool);

  /**
   * @notice Checks balance on a token
   * @param party Party params to check
   */
  function hasBalance(Party calldata party) external view returns (bool);

  /**
   * @notice Checks params for transfer
   * @param party Party params to check
   */
  function hasValidParams(Party calldata party) external view returns (bool);

  /**
   * @notice Function to wrap token transfer for different token types
   * @param from address Wallet address to transfer from
   * @param to address Wallet address to transfer to
   * @param amount uint256 Amount for ERC-20
   * @param id token ID for ERC-721
   * @param token address Contract address of token
   */
  function transfer(
    address from,
    address to,
    uint256 amount,
    uint256 id,
    address token
  ) external;
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":999999,"enabled":true},"libraries":{},"evmVersion":"paris"}
              

Contract ABI

[{"type":"error","name":"AmountOrIDInvalid","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasAllowance","inputs":[{"type":"tuple","name":"party","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasBalance","inputs":[{"type":"tuple","name":"party","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasValidParams","inputs":[{"type":"tuple","name":"party","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"interfaceId","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transfer","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50610492806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806347338bc31161005057806347338bc3146100aa578063a64d0cd4146100bf578063d1190df91461011757600080fd5b80633170f63d1461006c57806340944de914610094575b600080fd5b61007f61007a36600461037f565b61012a565b60405190151581526020015b60405180910390f35b61007f6100a236600461037f565b608001351590565b6100bd6100b83660046103bc565b6101ef565b005b6100e67f80ac58cd0000000000000000000000000000000000000000000000000000000081565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200161008b565b61007f61012536600461037f565b6102f2565b60003361013d604084016020850161041b565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526060850135600482015273ffffffffffffffffffffffffffffffffffffffff919091169063081812fc906024015b602060405180830381865afa1580156101ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d2919061043f565b73ffffffffffffffffffffffffffffffffffffffff161492915050565b821561025b576040517f94d40be700000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f616d6f756e740000000000000000000000000000000000000000000000000000604482015260640160405180910390fd5b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490528216906342842e0e90606401600060405180830381600087803b1580156102d357600080fd5b505af11580156102e7573d6000803e3d6000fd5b505050505050505050565b6000610301602083018361041b565b73ffffffffffffffffffffffffffffffffffffffff16610327604084016020850161041b565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526060850135600482015273ffffffffffffffffffffffffffffffffffffffff9190911690636352211e90602401610191565b600060a0828403121561039157600080fd5b50919050565b73ffffffffffffffffffffffffffffffffffffffff811681146103b957600080fd5b50565b600080600080600060a086880312156103d457600080fd5b85356103df81610397565b945060208601356103ef81610397565b93506040860135925060608601359150608086013561040d81610397565b809150509295509295909350565b60006020828403121561042d57600080fd5b813561043881610397565b9392505050565b60006020828403121561045157600080fd5b81516104388161039756fea2646970667358221220b06e3da58d258728f1004286fceef6f552766c64fdb0bf25b837a68a3d29030564736f6c63430008170033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100675760003560e01c806347338bc31161005057806347338bc3146100aa578063a64d0cd4146100bf578063d1190df91461011757600080fd5b80633170f63d1461006c57806340944de914610094575b600080fd5b61007f61007a36600461037f565b61012a565b60405190151581526020015b60405180910390f35b61007f6100a236600461037f565b608001351590565b6100bd6100b83660046103bc565b6101ef565b005b6100e67f80ac58cd0000000000000000000000000000000000000000000000000000000081565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200161008b565b61007f61012536600461037f565b6102f2565b60003361013d604084016020850161041b565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526060850135600482015273ffffffffffffffffffffffffffffffffffffffff919091169063081812fc906024015b602060405180830381865afa1580156101ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d2919061043f565b73ffffffffffffffffffffffffffffffffffffffff161492915050565b821561025b576040517f94d40be700000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f616d6f756e740000000000000000000000000000000000000000000000000000604482015260640160405180910390fd5b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490528216906342842e0e90606401600060405180830381600087803b1580156102d357600080fd5b505af11580156102e7573d6000803e3d6000fd5b505050505050505050565b6000610301602083018361041b565b73ffffffffffffffffffffffffffffffffffffffff16610327604084016020850161041b565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526060850135600482015273ffffffffffffffffffffffffffffffffffffffff9190911690636352211e90602401610191565b600060a0828403121561039157600080fd5b50919050565b73ffffffffffffffffffffffffffffffffffffffff811681146103b957600080fd5b50565b600080600080600060a086880312156103d457600080fd5b85356103df81610397565b945060208601356103ef81610397565b93506040860135925060608601359150608086013561040d81610397565b809150509295509295909350565b60006020828403121561042d57600080fd5b813561043881610397565b9392505050565b60006020828403121561045157600080fd5b81516104388161039756fea2646970667358221220b06e3da58d258728f1004286fceef6f552766c64fdb0bf25b837a68a3d29030564736f6c63430008170033