---
eip: 6604
label: ERC-6604
title: Abstract Token
status: Draft
type: Standards Track
category: ERC
created: 2023-03-03
requires: 20, 165, 721, 1155
official: https://eips.ethereum.org/EIPS/eip-6604
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6604.md
canonical: https://eips.huatuo.xyz/zh/eip-6604/
lang: zh
tldr: "一个草案标准：代币以签名或带证明的消息形式存在于链下，仅在需要时才在链上\"具现化（reify）\"，使大规模空投和凭证可以免费铸造。"
tags: [token, airdrop, minting, off-chain, draft]
---

# ERC-6604: Abstract Token

> move tokens on- and off-chain as desired, enabling zero-cost minting while preserving on-chain composability

**TL;DR:** 一个草案标准：代币以签名或带证明的消息形式存在于链下，仅在需要时才在链上"具现化（reify）"，使大规模空投和凭证可以免费铸造。

## 它解决什么问题？

铸造需要 gas。对于空投、POAP 式收据或访问凭证这类大批量、低价值的发放，预先铸造每一枚代币是浪费的，尤其是许多接收者根本不会使用它们。

各项目已经用 Merkle 树领取来绕开这个问题，但每个领取合约都有自己的证明格式和界面，没有定制集成的话，钱包也无法告诉用户"你有这些代币待领取"。

ERC-6604 定义了**抽象代币（abstract token）**：代币可以作为任何人都能检查的链下*消息*存在，只有当有人提交它时，才会变成普通的链上 [ERC-20](/eip-20/)、[ERC-721](/eip-721/) 或 [ERC-1155](/eip-1155/) 余额。

## 它如何运作

**代币消息。** 代币的链下形式：

```solidity
struct AbstractTokenMessage {
  uint256 chainId;        // where it can be reified
  address implementation; // which contract
  address owner;          // who receives it
  bytes   meta;           // implementation-specific: id, amount, uri…
  uint256 nonce;          // distinguishes otherwise-identical messages
  bytes   proof;          // Merkle proof, signature, etc.
}
```

**代币合约的核心方法：**

- `reify(message)`：验证证明并在链上铸造代币。每条消息最多只能使用一次；触发 `Reify` 事件。
- `status(message)`：返回 `invalid`、`valid` 或 `used`，因此钱包可以在任何铸造发生之前显示待领取的代币。
- `dereify(message)`（可选）：销毁链上代币，并将其转回供*另一个*合约或链使用的消息；触发 `Dereify` 事件。
- `id`、`amount`、`uri`（可选）：无需解析 `meta` 即可读取消息所代表的内容。

合约必须支持 [ERC-165](/eip-165/)。ERC-20/721/1155 的抽象版本增加了以消息作为额外参数的重载转账函数，因此接收者可以在一次调用中完成 reify 和转账。

`meta` 和 `proof` 有意设计为普通 bytes，因此任何资格验证方案（Merkle 树、发行方签名或新方案）都可以适用。

## 示例代码

钱包检查并领取抽象空投（ethers v6）：

```ts
import { Contract, Wallet, JsonRpcProvider } from "ethers";

const abi = [
  "function status((uint256 chainId,address implementation,address owner,bytes meta,uint256 nonce,bytes proof)) view returns (uint8)",
  "function amount((uint256,address,address,bytes,uint256,bytes)) view returns (uint256)",
  "function reify((uint256,address,address,bytes,uint256,bytes))",
];
const provider = new JsonRpcProvider(process.env.RPC_URL);
const token = new Contract(tokenAddress, abi, new Wallet(process.env.PRIVATE_KEY!, provider));

// `msg` was handed to the user off-chain, e.g. by the project's API
const msg = [chainId, tokenAddress, owner, meta, nonce, proof];
const s = await token.status(msg);            // 0 invalid, 1 valid, 2 used
if (s === 1n) {
  console.log("claimable:", await token.amount(msg));
  await (await token.reify(msg)).wait();
}
```

## 需要注意

- 状态为 **Draft**；名称和签名可能会改变。
- **丢失消息等于丢失代币。** 在 reify 之前，代币只是一条消息。发行方应为用户保存消息，最好由钱包来持有。
- 如果合约在遇到已使用的消息时 revert，任何持有副本的人都可以抢先交易，破坏所有者自己的 reify 调用；因此规范允许已使用的消息以空操作方式成功，而不是 revert。
- 单独把 dereify/reify 用作跨链桥是不安全的：链 B 无法得知该消息是否已在链 A 上被 dereify，因此需要预言机来防止双花。
- 证明方案不在规范范围内；总供应量是否可审计，完全取决于具体实现的选择。


---

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