Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC5700, a proposal for binding NFTs to other NFTs and subsequently unbinding them.

The following material is translated, summarized, and supplemented with explanations.

As of September 27, 2023, 5700 was at the Draft stage.

Overview

This standard provides a new mechanism for virtual worlds and digital assets. It defines tokens such as ERC721 and ERC1155 as bindable tokens and provides a way to associate them with an ERC721 NFT (non-fungible token).

For more on ERC721, see the following article.

https://chaldene.net/erc721

For more on ERC1155, see the following article.

https://chaldene.net/erc1155

When a bindable token is bound to an ERC721 NFT, ownership of the bindable token passes to the NFT. However, the NFT owner can unbind the tokens at any time and reclaim ownership of them. This mechanism allows bindable tokens to move with the NFT to which they are bound, enabling bundled transactions without additional fees. Multiple tokens can therefore be bundled with one NFT and transferred easily. Bound tokens remain locked until they are unbound, after which their ordinary token functionality becomes available again.

This standard is suitable for a range of applications.

Physical Assets Linked to NFTs

Examples include streetwear embedded with microchips, digitized car collections, and real estate using digital twin technology.

Digital Assets Linked to NFTs

Examples include accessories that can be added to virtual wardrobes, composable music tracks, and customizable metaverse land.

By making it easier to combine different tokens and NFTs, this standard enables new creative applications and opens opportunities in digital entertainment and assets.

Motivation

A standard interface can provide a smooth and efficient way to use NFTs (non-fungible tokens) and ordinary tokens together. It simplifies bundling and transferring NFTs and tokens while maintaining compatibility with wallets, marketplaces, and other NFT applications. The interface also eliminates the need to implement a specific, rigid token ownership strategy.

The standard aims to handle token ownership at the NFT level rather than binding ownership of ordinary tokens to a particular account. Specifically, it provides a general-purpose way to combine NFTs and tokens so they can be traded together. It works with the existing ERC721 and ERC1155 standards and maintains compatibility with them.

Using this standard simplifies transactions involving combinations of NFTs and tokens and provides consistent behavior across wallets, marketplaces, and other NFT applications. It makes it easy to integrate NFTs and tokens while avoiding complicated token ownership implementations.

Specification

ERC721 Bindable

Smart contracts implementing the ERC721 bindable standard must implement IERC721Bindable.

Developers implementing the IERC721Bindable interface must also follow a rule for the supportsInterface function. It must return true when passed the specific identifier 0x82a34a7d.

javascript
/// @title ERC-721 Bindable Token Standard
/// @dev See https://eips.ethereum.org/ERCS/eip-5700
///  Note: the ERC-165 identifier for this interface is 0x82a34a7d.
interface IERC721Bindable /* is IERC721 */ {

    /// @notice This event emits when an unbound token is bound to an NFT.
    /// @param operator The address approved to perform the binding.
    /// @param from The address of the unbound token owner.
    /// @param bindAddress The contract address of the NFT being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenId The identifier of binding token.
    event Bind(
        address indexed operator,
        address indexed from,
        address indexed bindAddress,
        uint256 bindId,
        uint256 tokenId
    );

    /// @notice This event emits when an NFT-bound token is unbound.
    /// @param operator The address approved to perform the unbinding.
    /// @param from The owner of the NFT the token is bound to.
    /// @param to The address of the new unbound token owner.
    /// @param bindAddress The contract address of the NFT being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenId The identifier of the unbinding token.
    event Unbind(
        address indexed operator,
        address indexed from,
        address to,
        address indexed bindAddress,
        uint256 bindId,
        uint256 tokenId
    );

    /// @notice Binds token `tokenId` to NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is the current owner, 
    ///  an authorized operator, or the approved address for the token. It also
    ///  MUST throw if the token is already bound or if `from` is not the token
    ///  owner. Finally, it MUST throw if the NFT contract does not support the
    ///  ERC-721 interface or if the NFT being bound to does not exist. Before 
    ///  binding, token ownership MUST be transferred to the contract address of
    ///  the NFT. On bind completion, the function MUST emit `Transfer` & `Bind` 
    ///  events to reflect the implicit token transfer and subsequent bind.
    /// @param from The address of the unbound token owner.
    /// @param bindAddress The contract address of the NFT being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenId The identifier of the binding token.
    function bind(
        address from,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId
    ) external;

    /// @notice Unbinds token `tokenId` from NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is the current owner, 
    ///  an authorized operator, or the approved address for the NFT the token
    ///  is bound to. It also MUST throw if the token is unbound, if `from` is
    ///  not the owner of the bound NFT, or if `to` is the zero address. After
    ///  unbinding, token ownership MUST be transferred to `to`, during which
    ///  the function MUST check if `to` is a valid contract (code size > 0),
    ///  and if so, call `onERC721Received`, throwing if the wrong identifier is
    ///  returned. On unbind completion, the function MUST emit `Unbind` &
    ///  `Transfer` events to reflect the unbind and subsequent transfer.
    /// @param from The address of the owner of the NFT the token is bound to.
    /// @param to The address of the unbound token new owner.
    /// @param bindAddress The contract address of the NFT being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenId The identifier of the unbinding token.
    function unbind(
        address from,
        address to,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId
    ) external;

    /// @notice Gets the NFT address and identifier token `tokenId` is bound to.
    /// @dev When the token is unbound, this function MUST return the zero
    ///  address for the address portion to indicate no binding exists.
    /// @param tokenId The identifier of the token being queried.
    /// @return The token-bound NFT contract address and numerical identifier.
    function binderOf(uint256 tokenId) external view returns (address, uint256);

    /// @notice Gets total tokens bound to NFT `bindId` at address `bindAddress`.
    /// @param bindAddress The contract address of the NFT being queried.
    /// @param bindId The identifier of the NFT being queried.
    /// @return The total number of tokens bound to the queried NFT.
    function boundBalanceOf(address bindAddress, uint256 bindId) external view returns (uint256);

Binder

javascript
struct Binder {
    address bindAddress;
    uint256 bindId;
}

Overview A struct containing the contract address and identifier of the NFT to which a bindable token is bound.

Parameters

  • bindAddress
    • The contract address of the NFT to which the bindable token is bound.
  • bindId
    • The identifier of the NFT to which the bindable token is bound.

boundBalanceOf

javascript
mapping(address => mapping(uint256 => uint256)) public boundBalanceOf; 

Overview An array tracking the token balance of each NFT bound through token binding.

Parameters

  • address
    • The user's address.
  • uint256
    • The NFT identifier.

_bound

javascript
mapping(uint256 => Binder) internal _bound;

Overview An array tracking information about NFTs and the bindable tokens bound to them.

Parameters

  • uint256
    • The NFT identifier.
  • Binder
    • A struct containing the contract address and identifier of the bound NFT.

_ERC165_INTERFACE_ID

javascript
bytes4 private constant _ERC165_INTERFACE_ID = 0x01ffc9a7;

Overview The identifier constant for the EIP165 interface.


_ERC721_BINDER_INTERFACE_ID

javascript
bytes4 private constant _ERC721_BINDER_INTERFACE_ID = 0x2ac2d2bc;

Overview The identifier constant for the ERC721 binder interface.


_ERC721_BINDABLE_INTERFACE_ID

javascript
bytes4 private constant _ERC721_BINDABLE_INTERFACE_ID = 0xd92c3ff0;

Overview The identifier constant for the ERC721 bindable interface.


binderOf

javascript
function binderOf(uint256 tokenId) public view returns (address, uint256) {
    Binder memory bound = _bound[tokenId];
    return (bound.bindAddress, bound.bindId);
}

Overview

Retrieves the address and identifier of the NFT to which a specified token ID is bound.

Details

The function accepts a token ID, retrieves its binding information from the internal _bound mapping, and returns that information. The binding information is represented by a Binder struct, from which the function obtains and returns the bound NFT's address and identifier.

Arguments

  • tokenId
    • The token ID for which to retrieve binding information.

Return Value

  • address
    • The address of the NFT to which the token is bound.
  • uint256
    • The numeric identifier of the NFT to which the token is bound.

bind

javascript
function bind(
        address from,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId
    ) public {
        if (
            _bound[tokenId].bindAddress != address(0) ||
            IERC721(bindAddress).ownerOf(bindId) == address(0)
        ) {
            revert BindInvalid();
        }

        if (from != _ownerOf[tokenId]) {
            revert OwnerInvalid();
        }

        if (
            msg.sender != from &&
            msg.sender != getApproved[tokenId] &&
            !_operatorApprovals[from][msg.sender]
        ) {
            revert SenderUnauthorized();
        }

        delete getApproved[tokenId];

        unchecked {
            _balanceOf[from]--;
            _balanceOf[bindAddress]++;
            boundBalanceOf[bindAddress][bindId]++;
        }

        _ownerOf[tokenId] = bindAddress;
        _bound[tokenId] = Binder(bindAddress, bindId);

        emit Transfer(from, bindAddress, tokenId);
        emit Bind(msg.sender, from,  bindAddress, bindId, tokenId);

}

Overview

Binds a token to a specific NFT.

Details

The function accepts the token owner (from), the target NFT address (bindAddress), the target NFT's numeric identifier (bindId), and the ID of the token to bind (tokenId). It performs several checks to validate the binding operation. If the conditions are not satisfied, the operation reverts (revert).

If the operation is valid, the token is removed from the owner and the target NFT's binding count is updated. The token owner is then changed to the target NFT, and the binding information is stored in the _bound mapping. Finally, a transaction event is emitted.

Arguments

  • from
    • The current token owner's address.
  • bindAddress
    • The contract address of the target NFT.
  • bindId
    • The numeric identifier of the target NFT.
  • tokenId
    • The ID of the token to bind.

unbind

javascript
function unbind(
        address from,
        address to,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId
    ) public {
        Binder memory bound = _bound[tokenId];
        if (
            bound.bindAddress != bindAddress ||
            bound.bindId != bindId ||
            _ownerOf[tokenId] != bindAddress
        ) {
            revert BindInvalid();
        }

        IERC721 binder = IERC721(bindAddress);

        if (from != binder.ownerOf(bindId)) {
            revert OwnerInvalid();
        }

        if (
            msg.sender != from &&
            msg.sender != binder.getApproved(tokenId) &&
            !binder.isApprovedForAll(from, msg.sender)
        ) {
            revert SenderUnauthorized();
        }

        if (to == address(0)) {
            revert ReceiverInvalid();
        }

        delete getApproved[tokenId];

        unchecked {
            _balanceOf[to]++;
            _balanceOf[bindAddress]--;
            boundBalanceOf[bindAddress][bindId]--;
        }

        _ownerOf[tokenId] = to;
        delete _bound[tokenId];

        emit Unbind(msg.sender, from, to, bindAddress, bindId, tokenId);
        emit Transfer(bindAddress, to, tokenId);

		if (
			to.code.length != 0 &&
				IERC721Receiver(to).onERC721Received(msg.sender, bindAddress, tokenId, "")
                !=
                IERC721Receiver.onERC721Received.selector
		) {
			revert SafeTransferUnsupported();
        }

}

Overview

Unbinds a token from a specific NFT.

Details

The function accepts the token owner (from), the new owner (to), the source NFT's address (bindAddress), its identifier (bindId), and the ID of the token to unbind (tokenId). It performs several checks to validate the unbinding operation. If the conditions are not satisfied, the operation reverts (revert).

If the operation is valid, token ownership changes and the binding information is removed from the _bound mapping. The token is transferred to its new owner, and a transaction event is emitted. If the recipient supports the ERC721 receiver interface, the corresponding function is also called.

Arguments

  • from
    • The address of the owner of the source NFT.
  • to
    • The address of the token's new owner after unbinding.
  • bindAddress
    • The contract address of the source NFT.
  • bindId
    • The identifier of the source NFT.
  • tokenId
    • The ID of the token to unbind.

supportsInterface

javascript
function supportsInterface(bytes4 id) public pure override(ERC721, IERC165) returns (bool) {
    return super.supportsInterface(id) || id == _ERC721_BINDABLE_INTERFACE_ID;
}

Overview

Checks whether a specified interface ID is supported.

Details

After checking for ERC721 and IERC165 support, the function checks whether the custom _ERC721_BINDABLE_INTERFACE_ID is supported. It returns true if supported, and false otherwise.

Arguments

  • id
    • The interface ID to check.

Return Value

  • bool
    • true if the specified interface ID is supported.
    • Otherwise, false.

ERC1155 Bindable

Smart contracts implementing the ERC1155 bindable standard must implement IERC1155Bindable.

Developers implementing the IERC1155Bindable interface must also follow a rule for the supportsInterface function. It must return true when passed the specific identifier 0xd0d55c6.

javascript
/// @title ERC-1155 Bindable Token Standard
/// @dev See https://eips.ethereum.org/ERCS/eip-5700
///  Note: the ERC-165 identifier for this interface is 0xd0d555c6.
interface IERC1155Bindable /* is IERC1155 */ {

    /// @notice This event emits when token(s) are bound to an NFT.
    /// @param operator The address approved to perform the binding.
    /// @param from The owner address of the unbound tokens.
    /// @param bindAddress The contract address of the NFT being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenId The identifier of the binding token type.
    /// @param amount The number of tokens binding to the NFT.
    event Bind(
        address indexed operator,
        address indexed from,
        address indexed bindAddress,
        uint256 bindId,
        uint256 tokenId,
        uint256 amount
    );

    /// @notice This event emits when token(s) of different types are bound to an NFT.
    /// @param operator The address approved to perform the batch binding.
    /// @param from The owner address of the unbound tokens.
    /// @param bindAddress The contract address of the NFTs being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenIds The identifiers of the binding token types.
    /// @param amounts The number of tokens per type binding to the NFTs.
    event BindBatch(
        address indexed operator,
        address indexed from,
        address indexed bindAddress,
        uint256 bindId,
        uint256[] tokenIds,
        uint256[] amounts
    );

    /// @notice This event emits when token(s) are unbound from an NFT.
    /// @param operator The address approved to perform the unbinding.
    /// @param from The owner address of the NFT the tokens are bound to.
    /// @param to The address of the unbound tokens' new owner.
    /// @param bindAddress The contract address of the NFT being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenId The identifier of the unbinding token type.
    /// @param amount The number of tokens unbinding from the NFT.
    event Unbind(
        address indexed operator,
        address indexed from,
        address to,
        address indexed bindAddress,
        uint256 bindId,
        uint256 tokenId,
        uint256 amount
    );

    /// @notice This event emits when token(s) of different types are unbound from an NFT.
    /// @param operator The address approved to perform the batch binding.
    /// @param from The owner address of the unbound tokens.
    /// @param to The address of the unbound tokens' new owner.
    /// @param bindAddress The contract address of the NFTs being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenIds The identifiers of the unbinding token types.
    /// @param amounts The number of tokens per type unbinding from the NFTs.
    event UnbindBatch(
        address indexed operator,
        address indexed from,
        address to,
        address indexed bindAddress,
        uint256 bindId,
        uint256[] tokenIds,
        uint256[] amounts
    );

    /// @notice Binds `amount` tokens of `tokenId` to NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is an approved operator
    ///  for `from`. It also MUST throw if the `from` owns fewer than `amount`
    ///  tokens. Finally, it MUST throw if the NFT contract does not support the
    ///  ERC-721 interface or if the NFT being bound to does not exist. Before 
    ///  binding, tokens MUST be transferred to the contract address of the NFT. 
    ///  On bind completion, the function MUST emit `Transfer` & `Bind` events 
    ///  to reflect the implicit token transfers and subsequent bind.
    /// @param from The owner address of the unbound tokens.
    /// @param bindAddress The contract address of the NFT being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenId The identifier of the binding token type.
    /// @param amount The number of tokens binding to the NFT.
    function bind(
        address from,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId,
        uint256 amount
    ) external;

    /// @notice Binds `amounts` tokens of `tokenIds` to NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is an approved operator
    ///  for `from`. It also MUST throw if the length of `amounts` is not the 
    ///  same as `tokenIds`, or if any balances of `tokenIds` for `from` is less
    ///  than that of `amounts`. Finally, it MUST throw if the NFT contract does 
    ///  not support the ERC-721 interface or if the bound NFT does not exist. 
    ///  Before binding, tokens MUST be transferred to the contract address of 
    ///  the NFT. On bind completion, the function MUST emit `TransferBatch` and
    ///  `BindBatch` events to reflect the batch token transfers and bind.
    /// @param from The owner address of the unbound tokens.
    /// @param bindAddress The contract address of the NFTs being bound to.
    /// @param bindId The identifier of the NFT being bound to.
    /// @param tokenIds The identifiers of the binding token types.
    /// @param amounts The number of tokens per type binding to the NFTs.
    function batchBind(
        address from,
        address bindAddress,
        uint256 bindId,
        uint256[] calldata tokenIds,
        uint256[] calldata amounts
    ) external;

    /// @notice Unbinds `amount` tokens of `tokenId` from NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is an approved operator
    ///  for `from`. It also MUST throw if `from` is not the owner of the bound
    ///  NFT, if the NFT's token balance is fewer than `amount`, or if `to` is 
    ///  the zero address. After unbinding, tokens MUST be transferred to `to`,
    ///  during which the function MUST check if `to` is a valid contract (code 
    ///  size > 0), and if so, call `onERC1155Received`, throwing if the wrong \
    ///  identifier is returned. On unbind completion, the function MUST emit 
    ///  `Unbind` & `Transfer` events to reflect the unbind and transfers.
    /// @param from The owner address of the NFT the tokens are bound to.
    /// @param to The address of the unbound tokens' new owner.
    /// @param bindAddress The contract address of the NFT being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenId The identifier of the unbinding token type.
    /// @param amount The number of tokens unbinding from the NFT.
    function unbind(
        address from,
        address to,
        address bindAddress,
        uint256 bindId,
        uint256 tokenId,
        uint256 amount
    ) external;

    /// @notice Unbinds `amount` tokens of `tokenId` from NFT `bindId` at address `bindAddress`.
    /// @dev The function MUST throw unless `msg.sender` is an approved operator
    ///  for `from`. It also MUST throw if the length of `amounts` is not the
    ///  same as `tokenIds`, if any balances of `tokenIds` for the NFT is less 
    ///  than that of `amounts`, or if `to` is the zero addresss. After 
    ///  unbinding, tokens MUST be transferred to `to`, during which the 
    ///  function MUST check if `to` is a valid contract (code size > 0), and if 
    ///  so, call `onERC1155BatchReceived`, throwing if the wrong identifier is 
    ///  returned. On unbind completion, the function MUST emit `UnbindBatch` & 
    ///  `TransferBatch` events to reflect the batch unbind and transfers.
    /// @param from The owner address of the unbound tokens.
    /// @param to The address of the unbound tokens' new owner.
    /// @param bindAddress The contract address of the NFTs being unbound from.
    /// @param bindId The identifier of the NFT being unbound from.
    /// @param tokenIds The identifiers of the unbinding token types.
    /// @param amounts The number of tokens per type unbinding from the NFTs.
    function batchUnbind(
        address from,
        address to,
        address bindAddress,
        uint256 bindId,
        uint256[] calldata tokenIds,
        uint256[] calldata amounts
    ) external;

    /// @notice Gets the number of tokens of type `tokenId` bound to NFT `bindId` at address `bindAddress`.
    /// @param bindAddress The contract address of the bound NFT.
    /// @param bindId The identifier of the bound NFT.
    /// @param tokenId The identifier of the token type bound to the NFT.
    /// @return The number of tokens of type `tokenId` bound to the NFT.
    function boundBalanceOf(
        address bindAddress,
        uint256 bindId,
        uint256 tokenId
    ) external view returns (uint256);

    /// @notice Gets the number of tokens of types `bindIds` bound to NFTs `bindIds` at address `bindAddress`.
    /// @param bindAddress The contract address of the bound NFTs.
    /// @param bindIds The identifiers of the bound NFTs.
    /// @param tokenIds The identifiers of the token types bound to the NFTs.
    /// @return balances The bound balances for each token type / NFT pair.
    function boundBalanceOfBatch(
        address bindAddress,
        uint256[] calldata bindIds,
        uint256[] calldata tokenIds
    ) external view returns (uint256[] memory balances);

}

This section covers only the elements not present in ERC721Bindable.

boundBalanceOf

javascript
mapping(address => mapping(uint256 => mapping(uint256 => uint256))) public boundBalanceOf;

Overview

An array tracking the bound balances associated with specific asset token types.

Details

The mapping has three levels. The first level is associated with an address (address) and tracks the bound balances of tokens held by that address. The second level is an identifier (uint256) representing a specific token type. The final level is another identifier (uint256) indicating a specific token ID.

Parameters

  • Address
    • The token owner's address.
  • Token type
    • A particular token type or identifier.
  • Token ID
    • The unique identifier of a particular token.

boundBalanceOfBatch

javascript
function boundBalanceOfBatch(
        address bindAddress,
        uint256[] calldata bindIds,
        uint256[] calldata tokenIds
    ) public view returns (uint256[] memory balances) {
        if (bindIds.length != tokenIds.length) {
            revert ArityMismatch();
        }

        balances = new uint256[](bindIds.length);

        unchecked {
            for (uint256 i = 0; i < bindIds.length; ++i) {
                balances[i] = boundBalanceOf[bindAddress][bindIds[i]][tokenIds[i]];
            }
        }
}

Overview Retrieves bound balances for multiple binding IDs and token IDs in a single operation.

Details

The function retrieves bound balances for multiple binding IDs and token IDs under the specified bindAddress. It returns the balances in an array containing the bound balance for each corresponding binding ID and token ID. If the bindIds and tokenIds arrays differ in length, the operation reverts (revert).

Arguments

  • bindAddress
    • The contract address of the bound NFT.
  • bindIds
    • An array of binding IDs.
  • tokenIds
    • An array of token IDs.

Return Value

  • balances
    • An array of bound balances corresponding to the binding IDs and token IDs.

batchBind

javascript
function batchBind(
        address from,
        address bindAddress,
        uint256 bindId,
        uint256[] calldata tokenIds,
        uint256[] calldata amounts
    ) public {
        if (msg.sender != from && !isApprovedForAll[from][msg.sender]) {
            revert SenderUnauthorized();
        }

        if (IERC721(bindAddress).ownerOf(bindId) == address(0)) {
            revert BindInvalid();
        }

        if (tokenIds.length != amounts.length) {
            revert ArityMismatch();
        }

        for (uint256 i = 0; i < tokenIds.length; i++) {
            _balanceOf[from][tokenIds[i]] -= amounts[i];
            _balanceOf[bindAddress][tokenIds[i]] += amounts[i];
            boundBalanceOf[bindAddress][bindId][tokenIds[i]] += amounts[i];
        }

		emit TransferBatch(msg.sender, from, bindAddress, tokenIds, amounts);
        emit BindBatch(msg.sender, from, bindAddress, bindId, tokenIds, amounts);

}

Overview

Binds multiple tokens to a specified NFT.

Details

The function accepts the specified owner (from), the target NFT's address (bindAddress), its numeric identifier (bindId), the IDs of the tokens to bind (tokenIds), and the amount for each token ID (amounts). It checks the owner's authorization and validates the binding operation. If the token ID and amount arrays differ in length, the operation reverts (revert).

If the binding operation is valid, the tokens are removed from the owner and the target NFT's bound balances are updated. Finally, a transaction event is emitted.

Arguments

  • from
    • The current token owner's address.
  • bindAddress
    • The contract address of the target NFT.
  • bindId
    • The numeric identifier of the target NFT.
  • tokenIds
    • An array of IDs of the tokens to bind.
  • amounts
    • An array of amounts to bind for each token ID.

batchUnbind

javascript
function batchUnbind(
        address from,
        address to,
        address bindAddress,
        uint256 bindId,
        uint256[] calldata tokenIds,
        uint256[] calldata amounts
    ) public {
        IERC721 binder = IERC721(bindAddress);

        if (binder.ownerOf(bindId) != from) {
            revert OwnerInvalid();
        }

        if (
            msg.sender != from &&
            msg.sender != binder.getApproved(bindId) &&
            !binder.isApprovedForAll(from, msg.sender)
        ) {
            revert SenderUnauthorized();
        }

        if (tokenIds.length != amounts.length) {
            revert ArityMismatch();
        }

        if (to == address(0)) {
            revert ReceiverInvalid();
        }

        for (uint256 i = 0; i < tokenIds.length; i++) {

            _balanceOf[to][tokenIds[i]] += amounts[i];
            _balanceOf[bindAddress][tokenIds[i]] -= amounts[i];
            boundBalanceOf[bindAddress][bindId][tokenIds[i]] -= amounts[i];
        }

        emit UnbindBatch(msg.sender, from, to, bindAddress, bindId, tokenIds, amounts);
		emit TransferBatch(msg.sender, from, bindAddress, tokenIds, amounts);

		if (
			to.code.length != 0 &&
				IERC1155Receiver(to).onERC1155BatchReceived(msg.sender, from, tokenIds, amounts, "")
                !=
                IERC1155Receiver.onERC1155BatchReceived.selector
		) {
			revert SafeTransferUnsupported();
        }
}

Overview

Unbinds multiple tokens from a specified NFT.

Details

The function accepts the specified owner (from), the new owner (to), the source NFT's address (bindAddress), its numeric identifier (bindId), the IDs of the tokens to unbind (tokenIds), and the amount for each token ID (amounts). It checks ownership and authorization and validates the unbinding operation. If the token ID and amount arrays differ in length, the operation reverts (revert).

If the unbinding operation is valid, token ownership changes and the bound balances are updated. A transaction event is also emitted. If the recipient supports the ERC-1155 batch receiver interface, the corresponding function is also called.

Arguments

  • from
    • The address of the owner of the source NFT.
  • to
    • The address of the token's new owner after unbinding.
  • bindAddress
    • The contract address of the source NFT.
  • bindId
    • The numeric identifier of the source NFT.
  • tokenIds
    • An array of IDs of the tokens to unbind.
  • amounts
    • An array of amounts to unbind for each token ID.

Additional Details

The token binding standard gives wallets, applications, and protocols a new way to bundle different digital assets and interact with, trade, or display them together with an NFT. This has practical applications in scenarios such as Dopamine. For example, streetwear can be packaged together with digital assets such as music, avatars, or digital twins of the clothing. These assets are represented by special bindable tokens, which are linked to a microchip represented as an NFT.

Binding Mechanism

During binding, ownership of the bindable token is transferred to the NFT to which it is bound. At the same time, the NFT owner can undo the binding at any time. A drawback is that applications that have not adopted the standard may not display the bundled tokens as belonging to the NFT owner.

When binding occurs, ownership of the bindable token formally passes to the NFT. Older applications that have not adopted this standard may have no way to determine whether the token is actually part of the NFT. Those applications therefore do not accurately display the bundled tokens as belonging to the NFT owner.

Applications must support the new standard to take full advantage of binding. This enables smooth integration between bindable tokens and NFTs and ensures ownership is displayed correctly.

Backwards Compatibility

The bindable token interfaces are compatible with the existing ERC721 and ERC1155 standards.

Reference Implementation

The reference implementation is available below.

Source: https://eips.ethereum.org/EIPS/eip-5700

Security Considerations

During binding, ownership of the bindable token passes to the contract of the NFT to which it is bound. Implementers must therefore exercise caution. Only the owner of the specific NFT must be able to perform an unbinding operation.

Once a binding is established, actual ownership of the bindable token passes to the bound NFT's contract. Unbinding must therefore be performed with security measures ensuring that only the rightful NFT owner can execute it. This prevents unauthorized users from unbinding tokens and protects security.

Citation

Leeren (@leeren), "ERC-5700: Bindable Token Interface [DRAFT]," Ethereum Improvement Proposals, no. 5700, September 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5700.

Conclusion

This article covered ERC5700, a proposal for binding NFTs to other NFTs and subsequently unbinding them. I hope you found it useful.

If you have questions, feel free to contact me by direct message on Twitter.

Twitter @cardene777

I also share information on other platforms, so feel free to explore them.

https://chaldene.net/