---
eip: 6454
label: ERC-6454
title: Minimal Transferable NFT detection interface
status: Final
type: Standards Track
category: ERC
created: 2023-01-31
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-6454
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6454.md
canonical: https://eips.huatuo.xyz/zh/eip-6454/
lang: zh
tldr: 一个只有一个函数的 ERC-721 扩展 isTransferable(tokenId, from, to)，让钱包和市场在尝试之前就能检查某个 NFT 是否可以转移，涵盖灵魂绑定和有条件锁定的代币。
tags: [nft, soulbound, non-transferable, erc-165]
---

# ERC-6454: Minimal Transferable NFT detection interface

> A minimal extension to identify the transferability of Non-Fungible Tokens.

**TL;DR:** 一个只有一个函数的 ERC-721 扩展 isTransferable(tokenId, from, to)，让钱包和市场在尝试之前就能检查某个 NFT 是否可以转移，涵盖灵魂绑定和有条件锁定的代币。

## 它解决什么问题？

有些 NFT 应当留在同一个账户中：成就徽章、资质凭证、玩家赢得的游戏内技能。项目可以通过重写转账函数来阻止转移，但这样一来，市场或钱包发现这一点的唯一办法就是模拟一次转账并观察其 revert，既浪费 gas，也给用户带来糟糕的体验。

ERC-6454 增加了尽可能小的信号：一个 view 函数，说明某个代币是否可以转移、从谁转给谁。

## 它如何运作

```solidity
function isTransferable(uint256 tokenId, address from, address to) external view returns (bool);
```

规则：

- 如果返回 `false`，实际的转账**必须** revert。
- 如果 `tokenId` 不存在，必须 revert，但检查某个代币能否被铸造时除外。
- `from` / `to` 参数让合约可以表达有条件的规则（例如"只能转给白名单地址"）。

以零地址作为约定：

| 问题 | `from` | `to` |
| --- | --- | --- |
| 这枚代币总体上是否可转移？ | `0x0` | `0x0` |
| 能否被铸造？（允许不存在的 `tokenId`） | `0x0` | 非零 |
| 能否被销毁？ | 非零 | `0x0` |

总体可转移性不涵盖铸造和销毁：总体上不可转移的代币仍必须拒绝所有普通转账，但可以被铸造或销毁。

规范有意**没有事件**，也**没有改变可转移性的函数**。代币可能在某个区块或满足某些条件后被锁定，此时并不存在可以 emit 事件的交易，因此该标准把状态管理留给各个实现。实现者也可以用 `from` 来检查授权，但调用者不应依赖这一点。

[ERC-165](/eip-165/) 接口 ID 为 `0x91a6262f`。

## 示例代码

一个可铸造、可销毁，但除此之外绑定于其所有者的徽章：

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

interface IERC6454 {
    function isTransferable(uint256 tokenId, address from, address to) external view returns (bool);
}

contract Badge is ERC721, IERC6454 {
    constructor() ERC721("Badge", "BDG") {}

    function isTransferable(uint256 tokenId, address from, address to) public view returns (bool) {
        if (from == address(0) && to != address(0)) return true;   // mint check
        _requireOwned(tokenId);                                    // revert if missing
        return to == address(0) && from != address(0);              // only burning allowed
    }

    function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
        address from = _ownerOf(tokenId);
        require(isTransferable(tokenId, from, to), "non-transferable");
        return super._update(to, tokenId, auth);
    }

    function supportsInterface(bytes4 id) public view override returns (bool) {
        return id == 0x91a6262f || super.supportsInterface(id);
    }
}
```

## 需要注意

- 状态为 **Final**。
- 可转移性可能随时间变化，所以 dApp 或市场应在每次展示或上架代币时重新检查，而不是缓存它。
- 恶意合约可能在 `isTransferable` 中说谎；该函数只是提示，而非保证。请验证你所集成的合约。
- 相关的锁定／灵魂绑定标准采用了不同的方法：[ERC-5192](/eip-5192/)（`locked` 加事件）、[ERC-6982](/eip-6982/)（节省 gas 的默认锁定状态）和 [ERC-7066](/eip-7066/)（由指定解锁者解锁的锁定）。


---

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