Abstract

This proposal introduces a smart contract wallet-based approach for managing NFTs, focusing on utilizing the programmable features of smart contract wallets for NFT asset management. Additionally, it introduces functions such as nftApprove, nftSetApprovalForOneAll, nftSetApprovalForAllAll, nftGetApproved, nftIsApprovedForOneAll, nftIsApprovedForAllAll and nftTransfer, which provide enhanced control over NFT transactions. This approach seeks to enhance NFT management by utilizing the built-in features of smart contract wallets, thus offering a more adaptable, secure, and efficient method for managing token transactions.

Motivation

An externally-owned account (EOA) wallet has no state and code storage, while the smart contract wallet does.

Account abstraction (AA) is a direction of the smart contract wallet, which works around abstract accounts. This ERC can also be an extension based on ERC-4337 or as a plug-in for wallets.

The smart contract wallet allows the user’s own account to have state and code, bringing programmability to the wallet. We think there are more directions to expand. For example, nft asset management, functional expansion of nft transactions, etc.

The smart contract wallet interface of this ERC is for nft asset management and nft asset approval. It supports the simplenft ERC-X, and ERC-721 is backward compatible with ERC-X, so it can be compatible with the management of all nfts in the existing market.

The proposal aims to achieve the following goals:

  1. NFT assets are allocated and managed by the wallet itself, such as approve function, which are configured by the user’s contract wallet, rather than controlled by the nft asset contract, to avoid some existing ERC-721 contract risks.
  2. Add the nftTransfer function, the transaction initiated by the non-smart wallet itself.
  3. Add nftApprove, nftSetApprovalForOneAll, nftSetApprovalForAllAll, nftGetApproved, nftIsApprovedForOneAll, nftIsApprovedForAllAll functions. The user wallet itself supports approve and provides approve. for One nft, all nft of one nft smart contract, all nft assets.
  4. User wallet can choose batch approve and batch transfer.
  5. Users can choose to add hook function before and after their nftTransfer to increase the user’s more playability.
  6. The user can choose to implement the nftReceive function.

Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 and RFC 8174.

Compliant contract must implement the ERC-165 interfaces


/// @title ERC-7564
/// @dev See https://eips.ethereum.org/EIPS/eip-7564
/// @dev Note: the ERC-165 identifier for this interface is 
pragma solidity ^0.8.20;

interface IERC7564{

    /**
     * @notice Used to notify listeners that owner has granted approval to the user to manage one nft.
     * @param _asset Address of the nft
     * @param _owner Address of the account that has granted the approval for nft‘s assets
     * @param _operator Address of the operator
     * @param _tokenId The unique identifier of the NFT
     */
    event NftApproval(
        address indexed _asset,
        address indexed _owner, 
        address indexed _operator, 
        uint256 _tokenId
    );

    /**
     * @notice Used to notify listeners that owner has granted approval to the operator to manage all nft of one asset contract.
     * @param _asset Address of the nft
     * @param _owner Address of the account that has granted the approval for nft‘s assets
     * @param _operator Address of the operator
     * @param _approved approve all nft of one asset contract
     */
    event NftApprovalForOneAll(
        address indexed _asset,
        address indexed _owner, 
        address indexed _operator,
        bool _approved
    );

    /**
     * @notice Used to notify listeners that owner has granted approval to the operator to manage all nft .
     * @param _owner Address of the account that has granted the approval for nft‘s assets
     * @param _operator Address of the operator
     * @param _approved approve all nft
     */
    event NftApprovalForAllAll(
        address indexed _owner, 
        address indexed _operator,
        bool _approved
    );

    /**
     * @notice Approve nft
     * @dev Allows operator address to withdraw from your wallet one nft.
     * @dev Emits an {nftApproval} event.
     * @param _asset Address of the nft
     * @param _operator Address of the operator
     * @param _tokenId The unique identifier of the NFT
     */
    function nftApprove(address _asset, address _operator, uint256 _tokenId) external;

   

    /**
     * @notice Approve all nft of one asset
     * @dev Allows operator address to withdraw from your wallet all nft.
     * @dev Emits an {nftApprovalForOneAll} event.
    * @param _asset Address of the nft
     * @param _operator Address of the operator
     * @param _approved Approved all nfts of one asset
     */
    function nftSetApprovalForOneAll(address _asset, address _operator, bool _approved) external;


     /**
     * @notice Approve all nft
     * @dev Allows operator address to withdraw from your wallet all nft.
     * @dev Emits an {nftApprovalForAllAll} event.
     * @param _operator Address of the operator
     * @param _approved Approved all nfts
     */
    function nftSetApprovalForAllAll(address _operator, bool _approved) external;

    /**
     * @notice read operator approved
     * @param _asset Address of the nft
     * @param _operator Address of the operator
     * @param _tokenId The unique identifier of the NFT
     * @return _approved Whether to approved operator one nft
     */
    function nftGetApproved(address _asset, address _operator, uint256 _tokenId) 
        external
        view
        returns (bool _approved);

    /**
     * @notice read operator approved
     * @param _asset Address of the nft
     * @param _operator Address of the operator
     * @return _approved Whether to approved operator all nfts of this one asset
     */
    function nftIsApprovedForOneAll(address _asset, address _operator) 
        external
        view
        returns (bool _approved);

    /**
     * @notice read operator approved
     * @param _operator Address of the operator
     * @return _approved Whether to approved operator all nfts
     */
    function nftIsApprovedForAllAll(address _operator) 
        external
        view
        returns (bool _approved);

    /**
     * @notice Transfer nft
     * @dev must call nft asset transfer() inside the function
     * @dev If the caller is not wallet self, must verify the approve and update
     * @param _asset Address of the nft
     * @param _to Address of the receive
     * @param _tokenId The transaction amount
     * @return _success The bool value returns whether the transfer is successful
     */
    function nftTransfer(address _asset, address _to, uint256 _tokenId) 
        external 
        returns (bool _success); 


}

Rationale

the key technical decisions in this proposal are:

Improved Approve Mechanism

  • Current vs. Proposed: In the existing ERC-721 system, an externally-owned account (EOA) directly interacts with nft contracts to approve. The new nftApprove, nftSetApprovalForOneAll, nftSetApprovalForAllAll, nftGetApproved, nftIsApprovedForOneAll, nftIsApprovedForAllAllfunctions in this proposed enable more precise control over nft usage within a wallet contract, a significant improvement over the traditional method.
  • Enhanced Security: This mechanism mitigates risks like nft over-approval by shifting approval control to the user’s smart contract wallet.
  • Programmability: Users gain the ability to set advanced approval strategies, such as conditional or time-limited approvals, the nftSetApprovalForAllAll function specifically allows for a universal setting all nfts. these were not possible with traditional ERC-721 nfts.

Optimized Transfer Process

  • Efficiency and Security: The nftTransfer function streamlines the nft transfer process, making transactions both more efficient and secure.
  • Flexibility: Allows the integration of custom logic (hooks) before and after transfers, enabling additional security checks or specific actions tailored to the user’s needs.

Support for Batch Operations

  • Increased Efficiency: Users can simultaneously handle multiple approve or transfer operations, significantly boosting transaction efficiency.
  • Enhanced User Experience: Simplifies the management of numerous assets, improving the overall experience for users with large portfolios.

Backwards Compatibility

This ERC can be used as an extension of ERC-4337 and is backward compatible with ERC-4337.

Security Considerations

No security considerations were found.

Copyright and related rights waived via CC0.