---
eip: 7994
label: ERC-7994
title: Purpose-Bound ERC-20 with Conditional Unlock
status: Final
type: Standards Track
category: ERC
created: 2025-07-29
requires: 20, 7291
official: https://eips.ethereum.org/EIPS/eip-7994
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7994.md
canonical: https://eips.huatuo.xyz/zh/eip-7994/
lang: zh
tldr: "扩展 ERC-20，使代币可以为某个接收方锁定，直到多个条件（时间、KYC、白名单等）全部满足，建立在 ERC-7291 的\"用途绑定货币\"理念之上。"
tags: [token, erc20, conditional, compliance, payments]
---

# ERC-7994: Purpose-Bound ERC-20 with Conditional Unlock

> Extends ERC-20 with programmable restrictions, enabling transfers based on multiple unlock conditions as defined in EIP-7291.

**TL;DR:** 扩展 ERC-20，使代币可以为某个接收方锁定，直到多个条件（时间、KYC、白名单等）全部满足，建立在 ERC-7291 的"用途绑定货币"理念之上。

## 它解决什么问题？

[ERC-7291](/eip-7291/) 提出了"用途绑定货币"（purpose-bound money）：对如何使用、在哪里使用有限制的代币。许多现实场景需要同时满足多个条件，资金才能使用。例如：

- 奖学金只发放给通过 KYC 验证、年龄在 25 岁以下且就读于某所大学的学生。
- NGO 援助款只能用于食品和药品，并且只能在某个日期之后使用。
- 每月解锁、且只能在获批商户处消费的工资代币。

ERC-7994 为 [ERC-20](/eip-20/) 代币增加了一种标准方式：为接收方在一组条件之后锁定一定数量，并且只有在所有条件都满足时才释放。

## 它如何运作

每一笔被锁定的转账称为一个 **purpose binding**。它包含：

- 一个 `recipient` 和一个 `amount`，
- 一组 `UnlockCondition`，每个由 `conditionType`（`bytes32` 标签，如 `"TIME"`、`"KYC"` 或 `"WHITELIST"`）和用于评估它的 `conditionData`（时间戳、Merkle root 等）组成，
- 可选的 `expiry`，超过该时间后该 binding 不能再被领取。

接口由三个函数组成：

- `bindPurpose(recipient, amount, conditions, expiry)` 锁定代币并返回 `bindingId`。
- `isUnlocked(bindingId)` 仅当每个条件当前都已满足时才返回 true。
- `claim(bindingId)` 让接收方在解锁后取走代币。

在参考实现中，每个 `conditionType` 对应一个独立的检查器合约，其带有 `isConditionMet(recipient, conditionData)`，因此无需修改代币即可接入新的条件类型。代币被锁定期间由代币合约自身持有。

## 示例代码

标准中的接口：

```solidity
pragma solidity ^0.8.23;

interface IPurposeBoundERC20 {
    struct UnlockCondition {
        bytes32 conditionType; // e.g. "TIME", "KYC", "WHITELIST"
        bytes conditionData;   // e.g. timestamp, Merkle root
    }

    function bindPurpose(
        address recipient,
        uint256 amount,
        UnlockCondition[] calldata conditions,
        uint256 expiry
    ) external returns (bytes32 bindingId);

    function claim(bytes32 bindingId) external;
    function isUnlocked(bytes32 bindingId) external view returns (bool);
}
```

锁定代币直到某个日期（ethers v6）：

```ts
import { AbiCoder, encodeBytes32String } from "ethers";

const unlockAt = BigInt(Math.floor(Date.parse("2027-01-01") / 1000));
const conditions = [{
  conditionType: encodeBytes32String("TIME"),
  conditionData: AbiCoder.defaultAbiCoder().encode(["uint256"], [unlockAt]),
}];
const tx = await token.bindPurpose(student, amount, conditions, 0n); // 0 = no expiry
await tx.wait();
```

## 需要注意

- 该标准被标记为 Final。
- 接口没有定义事件、条件类型如何注册，以及 `expiry` 之后代币如何处理；这些都留给具体实现。请确认某个代币如何处理已过期且未被领取的资金。
- 在参考实现中，`setConditionResolver` 是"为演示目的"而公开的。生产环境的代币必须限制谁能注册检查器，否则任何人都可以接入一个永远返回 true 的检查器。
- 像 KYC 这样的链下检查取决于维护链上证明（例如 Merkle root）的一方。代币的可信度取决于这些检查器。
- Binding ID 必须唯一，且 `claim` 必须原子性地验证所有条件，以避免重放和部分领取的漏洞。


---

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