---
eip: 2019
label: ERC-2019
title: Fundable Token
status: Stagnant
type: Standards Track
category: ERC
created: 2019-05-10
requires: 20
official: https://eips.ethereum.org/EIPS/eip-2019
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2019.md
canonical: https://eips.huatuo.xyz/zh/eip-2019/
lang: zh
tldr: 一个 ERC-20 扩展，让钱包所有者可以在链上请求新代币（例如换取法币付款），由运营方处理、执行或拒绝每一笔充值订单。
tags: [token, erc20, e-money, minting, payments]
---

# ERC-2019: Fundable Token

> An extension to the [ERC-20] standard token that allows Token wallet owners to request a wallet to be funded, by calling the smart contract and attaching a fund instruction string.

**TL;DR:** 一个 ERC-20 扩展，让钱包所有者可以在链上请求新代币（例如换取法币付款），由运营方处理、执行或拒绝每一笔充值订单。

## 它解决什么问题？

对于受监管、以法币为支撑的代币（银行货币、电子货币），把代币放进你的钱包通常从链下开始：你先发起银行转账，然后发行方铸造。请求本身在链上是看不见的。

ERC-2019 把*请求*搬到链上。钱包所有者提交带有支付指示的充值订单；代币运营方处理订单并记录每次状态变化。这为充值提供了可追踪、可审计的生命周期，而具体的支付细节仍保留在私有渠道中。

它是同一作者为电子货币代币提出的一系列提案之一，与 [Holdable](/eip-1996/)、[Clearable](/eip-2018/) 以及总括性的 [E-Money](/eip-2020/) 代币并列。

## 它如何运作

三个角色：**钱包所有者**、获授权代其操作的可选 **orderer**，以及负责铸造的代币**运营方**。

每个订单由字符串 `operationId` 标识，状态流转如下：

```
Ordered ──processFund──▶ InProcess ──executeFund──▶ Executed (tokens minted)
   │                         └──────rejectFund────▶ Rejected
   └──cancelFund──▶ Cancelled   (only before InProcess)
```

主要函数：

| 函数 | 调用者 | 用途 |
| --- | --- | --- |
| `authorizeFundOperator(orderer)` / `revokeFundOperator` | 所有者 | 允许或停止另一个地址代你下单 |
| `orderFund(id, value, instructions)` | 所有者 | 请求为自己的钱包充值 |
| `orderFundFrom(id, wallet, value, instructions)` | orderer | 代表所有者发起请求 |
| `cancelFund(id)` | 所有者/orderer | 在处理开始前取消 |
| `processFund(id)` / `executeFund(id)` / `rejectFund(id, reason)` | 运营方 | 推进订单；execute 会铸造代币 |
| `retrieveFundData(orderer, id)` | view | 钱包、金额、指示、状态 |

每一步都会触发事件（`FundOrdered`、`FundInProcess`、`FundExecuted`、`FundRejected`、`FundCancelled` 等）。拒绝原因可以使用 [ERC-1066](/eip-1066/) 状态码。`operationId` 不得重复使用。

## 示例代码

用 ethers v6 下达并监听充值请求：

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

const abi = [
  "function orderFund(string operationId, uint256 value, string instructions) returns (bool)",
  "event FundExecuted(address indexed orderer, string indexed operationId)",
];
const token = new Contract(tokenAddress, abi, signer);

const opId = `acme-${crypto.randomUUID()}`;          // prefix to avoid collisions
await token.orderFund(opId, parseUnits("250", decimals), "ref:INV-2041"); // keep sensitive data off-chain

token.on("FundExecuted", (orderer, _opIdHash, ev) => {
  if (orderer === signer.address) console.log("funded in", ev.log.transactionHash);
});
```

## 需要注意

- 状态为 **Stagnant**。接口没有最终确定。
- 规范警告不要把银行或路由信息以明文放到链上。请使用链下渠道，或者至少对 `instructions` 字符串加密。
- `operationId` 是共享命名空间，因此请使用唯一前缀。由于事件把它作为 `string` 建立索引，日志中只包含它的哈希。
- 运营方是否兑现或拒绝请求完全取决于对其的信任；该标准只记录流程，并不强制付款。


---

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