---
eip: 5700
label: ERC-5700
title: Bindable Token Interface
status: Draft
type: Standards Track
category: ERC
created: 2022-09-22
requires: 165, 721, 1155
official: https://eips.ethereum.org/EIPS/eip-5700
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5700.md
canonical: https://eips.huatuo.xyz/zh/eip-5700/
lang: zh
tldr: "一个草案接口，让 ERC-721 或 ERC-1155 代币可以\"绑定\"到某个 NFT 上，从而在该 NFT 转移时随之转移，直到其所有者解除绑定。"
tags: [nft, bundling, composability, token, draft]
---

# ERC-5700: Bindable Token Interface

> Interface for binding fungible and non-fungible tokens to assets.

**TL;DR:** 一个草案接口，让 ERC-721 或 ERC-1155 代币可以"绑定"到某个 NFT 上，从而在该 NFT 转移时随之转移，直到其所有者解除绑定。

## 它解决什么问题？

有时几枚代币是属于一起的：一件实体与数字结合（phygital）的服装 NFT，加上随附的音乐、头像和数字孪生；或者一块虚拟土地及其装饰。移动这样一个组合通常需要逐个转移每枚代币，而链上也没有任何记录说明它们属于一起。

ERC-5700 定义了"可绑定"代币。可绑定的 [ERC-721](/eip-721/) 或 [ERC-1155](/eip-1155/) 代币可以绑定到某个特定的 ERC-721 NFT。一旦绑定，它就归 NFT 本身所有，而不是归某个钱包所有，因此每当 NFT 易主时，被绑定的代币就会隐式地随之转移，不需要额外成本。当前 NFT 所有者可以随时解除绑定，拿回普通的、可转移的代币。

## 它如何运作

- **绑定。** `bind(from, bindAddress, bindId, tokenId)` 把代币从 `from` 转移到 `bindAddress` 处的 NFT 合约，并记录它属于 NFT `bindId`。如果目标合约不是 ERC-721，或该 NFT 不存在，必须回滚。会触发 `Transfer` 和 `Bind` 事件。
- **解除绑定。** `unbind(from, to, bindAddress, bindId, tokenId)` 只能由代币所绑定的 NFT 的所有者（或被授权的 operator）调用。所有权转给 `to`，如果 `to` 是合约，则执行常规的 safe-transfer 接收方检查。会触发 `Unbind` 和 `Transfer` 事件。
- **查询。** `binderOf(tokenId)` 返回代币所绑定的 NFT（未绑定则为零地址），`boundBalanceOf(bindAddress, bindId)` 统计绑定到某个 NFT 的代币数量。
- ERC-1155 版本增加了数量和批量变体：`batchBind`、`batchUnbind`、`boundBalanceOfBatch`，以及 `BindBatch` / `UnbindBatch` 事件。

两种接口都通过 [ERC-165](/eip-165/) 检测；ERC-721 版本的接口 ID 是 `0x82a34a7d`。

## 示例代码

把一个配饰代币绑定到"衣橱"NFT，之后再取回（ERC-721 版本）：

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERC721Bindable {
    event Bind(address indexed operator, address indexed from,
        address indexed bindAddress, uint256 bindId, uint256 tokenId);
    event Unbind(address indexed operator, address indexed from, address to,
        address indexed bindAddress, uint256 bindId, uint256 tokenId);

    function bind(address from, address bindAddress, uint256 bindId, uint256 tokenId) external;
    function unbind(address from, address to, address bindAddress, uint256 bindId, uint256 tokenId) external;
    function binderOf(uint256 tokenId) external view returns (address, uint256);
    function boundBalanceOf(address bindAddress, uint256 bindId) external view returns (uint256);
}

contract Example {
    function attach(IERC721Bindable accessory, address wardrobe, uint256 wardrobeId, uint256 hatId) external {
        // caller must own (or be approved for) hatId
        accessory.bind(msg.sender, wardrobe, wardrobeId, hatId);
    }

    function detach(IERC721Bindable accessory, address wardrobe, uint256 wardrobeId, uint256 hatId) external {
        // caller must own (or be approved for) the wardrobe NFT
        accessory.unbind(msg.sender, msg.sender, wardrobe, wardrobeId, hatId);
    }
}
```

## 需要注意

- 状态为 **Draft**：接口仍可能变化，不应被视为已确定的标准。
- 不理解 ERC-5700 的应用会把被绑定的代币显示为归 NFT 合约地址所有，而不是归 NFT 的所有者所有。规范把这点列为这种轻量设计的已知权衡。
- 安全性取决于解除绑定仅限于所绑定 NFT 的当前所有者或 operator；在任何实现中都要仔细审查这项检查。
- 规范正文与接口注释对 ERC-1155 可绑定接口 ID 的说法不一致，因此在依赖之前请对照参考实现进行验证。
- 对同一个"NFT 拥有事物"想法的另一种做法是 [ERC-6551](/eip-6551/)，它为每个 NFT 提供自己的智能账户；[ERC-998](/eip-998/) 是更早的可组合 NFT 草案。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5700
