---
eip: 3386
label: ERC-3386
title: ERC-721 and ERC-1155 to ERC-20 Wrapper
status: Stagnant
type: Standards Track
category: ERC
created: 2021-03-12
requires: 165
official: https://eips.ethereum.org/EIPS/eip-3386
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-3386.md
canonical: https://eips.huatuo.xyz/zh/eip-3386/
lang: zh
tldr: 一个停滞（Stagnant）的接口：用于锁定 ERC-721 或 ERC-1155 代币并据此铸造同质化 ERC-20 代币的池，这些代币之后可以销毁，以赎回随机或指定的 NFT。
tags: [nft, erc20, wrapper, fractionalization, defi]
---

# ERC-3386: ERC-721 and ERC-1155 to ERC-20 Wrapper

> A standard interface for contracts that create generic ERC-20 tokens which derive from a pool of unique ERC-721/ERC-1155 tokens.

**TL;DR:** 一个停滞（Stagnant）的接口：用于锁定 ERC-721 或 ERC-1155 代币并据此铸造同质化 ERC-20 代币的池，这些代币之后可以销毁，以赎回随机或指定的 NFT。

## 它解决什么问题？

NFT（[ERC-721](/eip-721/)）和多代币（[ERC-1155](/eip-1155/)）按单个 ID、以整份为单位转移。这使它们很难融入围绕 [ERC-20](/eip-20/) 构建的庞大生态：AMM、借贷市场和指数产品无法以通用方式交易或定价“这个系列中的一枚 NFT”。

一些项目（规范中提到了 NFTX、NFT20、wrapped CryptoKitties、wrapped MoonCats）通过把 NFT 放入池中，并发行代表对池中*某一个*物品之索取权的同质化代币来解决这个问题。每个项目都使用自己的接口。EIP-3386 为它们提出了一个统一的通用接口 `IWrapper`。

## 它如何运作

规范列出三种角色，它们可以全部是同一个合约：

- **Base：**被包装的 ERC-721 或 ERC-1155 代币。
- **Pool：**持有已存入 Base 代币的合约。
- **Derivative：**由包装器铸造和销毁的 ERC-20 代币。

**铸造：**`mint(to, id, amount)` 或 `batchMint(to, ids, amounts)` 把 Base 代币从 `msg.sender` 拉入池中，并向 `to` 铸造 Derivative 代币。已存入的 Base 代币除了通过销毁之外，不得离开池。

**销毁**有两种：

- `burn(from, to, amount)` / `batchBurn(...)`：销毁 Derivative 并获得*某一个* Base 代币；不保证是哪一个。
- `idBurn(from, to, id, amount)` / `batchIdBurn(...)`：销毁 Derivative 以赎回*指定的* ID，实现可以为它定不同的价格。

每个操作都会触发 `MintSingle`、`MintBatch`、`BurnSingle` 或 `BurnBatch`。对于 ERC-721，每个 `amount` 都是 1。Base 与 Derivative 之间的兑换比率由实现自行决定（固定，或由荷兰式拍卖等机制设定）。合约还必须实现 [ERC-165](/eip-165/)。

## 示例代码

接口的核心部分，以及一个包装单个 NFT 的客户端（ethers v6）：

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

interface IWrapper /* is ERC165 */ {
    event MintSingle(address indexed _from, address indexed _to, uint256 _id, uint256 _amount, uint256 _value);
    event BurnSingle(address indexed _from, address indexed _to, uint256 _id, uint256 _amount, uint256 _value);

    function mint(address _to, uint256 _id, uint256 _amount) external;
    function burn(address _from, address _to, uint256 _amount) external;
    function idBurn(address _from, address _to, uint256 _id, uint256 _amount) external;
}
```

```ts
import { Contract } from "ethers";

const nft = new Contract(nftAddress, ["function setApprovalForAll(address,bool)"], signer);
const wrapper = new Contract(wrapperAddress, [
  "function mint(address,uint256,uint256)",
  "function idBurn(address,address,uint256,uint256)",
], signer);

await (await nft.setApprovalForAll(wrapperAddress, true)).wait();
await (await wrapper.mint(await signer.getAddress(), 42n, 1n)).wait(); // deposit NFT #42, receive ERC-20
```

## 需要注意

- 状态为 **Stagnant**：它从未达到 Final，现有的 NFT 池协议使用各自的接口。
- 在固定兑换比率下，Derivative 跟踪的是池的**地板价**价值；除非实现对各个 ID 单独定价，否则稀有物品的持有者把它存入就会损失价值。
- 不带 ID 的 `burn` 得到的是池所选的任意物品，因此想要特定物品的用户必须使用 `idBurn`。
- 规范没有定义读取兑换比率或池内容的标准方法；实现必须自行说明这些。


---

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