---
eip: 5744
label: ERC-5744
title: Latent Fungible Token
status: Stagnant
type: Standards Track
category: ERC
created: 2022-09-29
requires: 20, 2612
official: https://eips.ethereum.org/EIPS/eip-5744
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5744.md
canonical: https://eips.huatuo.xyz/zh/eip-5744/
lang: zh
tldr: 一个 ERC-20 扩展，适用于每次铸造时先被锁定、在经过到期延迟后才变得可自由流通（同质化）的代币，适合用于归属（vesting）和最低存款期限的凭证。
tags: [token, erc20, vesting, defi, extension]
---

# ERC-5744: Latent Fungible Token

> An interface for tokens that become fungible after a period of time.

**TL;DR:** 一个 ERC-20 扩展，适用于每次铸造时先被锁定、在经过到期延迟后才变得可自由流通（同质化）的代币，适合用于归属（vesting）和最低存款期限的凭证。

## 它解决什么问题？

有些代币不应该在铸造的那一刻就完全可用：

- **归属代币**（vesting tokens），在归属期结束前不得转让。
- 借贷或保险协议的**凭证代币**，用于强制最短存款期限。

项目用自定义逻辑实现这些，但钱包和集成方没有标准方式来询问"这笔余额现在实际可用多少？"。ERC-5744（"Latent Fungible Token"）在 [ERC-20](/eip-20/) 之上定义了这个接口。

## 它如何运作

潜在同质化代币（latent fungible token）是在普通 ERC-20 基础上增加两样东西：

- `balanceOfMatured(user)` 只返回余额中**已到期**（可同质化流通）的部分。`balanceOf` 和 `totalSupply` 仍然统计全部，无论是否到期。
- `getMints(user)` 以 `MintMetadata { amount, time, delay }` 的形式返回某用户的每一次铸造：铸造了多少、何时铸造（以秒为单位的时间戳），以及距离到期的延迟（秒）。如果到期取决于经过时间以外的因素，`delay` 必须是 `type(uint256).max`。

可选的 `mints(user, id)` 通过由实现自行定义的 ID 返回单次铸造。

实现**可以**让 `transfer`、`transferFrom` 和销毁对未到期的代币 revert。归属代币会这样做；凭证代币则可能允许随时转让，只在其他地方使用到期信息。代币必须实现 ERC-20 可选的 `name` / `symbol`，并且它们必须以某种方式反映底层代币。

规范将 [ERC-2612](/eip-2612/)（`permit`）列为必需项。

## 示例代码

读取可用余额与总余额（ethers v6）：

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

const abi = [
  "function balanceOf(address) view returns (uint256)",
  "function balanceOfMatured(address) view returns (uint256)",
  "function getMints(address) view returns (tuple(uint256 amount, uint256 time, uint256 delay)[])",
  "function decimals() view returns (uint8)",
];

const provider = new JsonRpcProvider(process.env.RPC_URL);
const token = new Contract(process.env.TOKEN!, abi, provider);

const user = process.env.USER_ADDRESS!;
const [total, matured, mints, dec] = await Promise.all([
  token.balanceOf(user),
  token.balanceOfMatured(user),
  token.getMints(user),
  token.decimals(),
]);

console.log("total  :", formatUnits(total, dec));
console.log("usable :", formatUnits(matured, dec));

const MAX = (1n << 256n) - 1n;
for (const m of mints) {
  const when = m.delay === MAX ? "condition-based" : new Date(Number(m.time + m.delay) * 1000).toISOString();
  console.log(formatUnits(m.amount, dec), "matures:", when);
}
```

## 需要注意

- 状态为 **Stagnant**：近期没有动静，可能永远不会定稿。
- 不要假定 `balanceOf` 是可花费的。当代币可能阻止未到期代币的转让时，集成方（DEX、借贷市场）应使用 `balanceOfMatured`。
- `getMints` 返回一个无界数组。在链上遍历它可能超出区块 gas 上限；如果用户可能积累大量铸造记录，规范建议使用分页版本。
- 与 ERC-20 工具完全向后兼容，这些工具只会看到总余额。


---

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