{"eip":5507,"title":"Refundable Tokens","description":"Adds refund functionality to ERC-20, ERC-721, and ERC-1155 tokens","authors":["elie222 (@elie222)","Gavin John (@Pandapip1)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2022-08-19","requires":[20,165,721,1155],"discussionsTo":"https://ethereum-magicians.org/t/eip-5507-refundable-nfts/10451","repo":"ERCs","label":"ERC-5507","officialUrl":"https://eips.ethereum.org/EIPS/eip-5507","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5507.md","url":"https://eips.huatuo.xyz/eip-5507/","tldr":{"en":"Adds a standard refund interface to ERC-20, ERC-721 and ERC-1155 sales: buyers can return tokens for ETH until a deadline block, after which the creator can claim the escrowed funds.","ja":"ERC-20、ERC-721、ERC-1155 のセールに標準の返金インターフェースを追加する。購入者は期限のブロックまでトークンを返して ETH を取り戻せ、期限後は作成者がエスクローされた資金を引き出せる。","ko":"ERC-20, ERC-721, ERC-1155 판매에 표준 환불 인터페이스를 추가한다. 구매자는 마감 블록까지 토큰을 반환하고 ETH를 돌려받을 수 있으며, 그 이후에는 제작자가 에스크로된 자금을 청구할 수 있다.","zh":"为 ERC-20、ERC-721 和 ERC-1155 的销售增加标准退款接口：买家可在截止区块之前退回代币换回 ETH，之后创建者可以领取托管的资金。"},"tags":["token","nft","refund","escrow"],"explainers":{"en":{"lang":"en","tldr":"Adds a standard refund interface to ERC-20, ERC-721 and ERC-1155 sales: buyers can return tokens for ETH until a deadline block, after which the creator can claim the escrowed funds.","tags":["token","nft","refund","escrow"],"related":[20,721,1155,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5507/","markdown":"## What problem does it solve?\n\nToken and NFT launches often take buyers' ETH up front and give no recourse if the project disappears (\"rug pull\"). Some projects promised refunds, but each implemented them differently, so wallets and marketplaces could not show or trigger them.\n\nERC-5507 standardizes a refund window for initial sales. Funds stay in escrow until a predetermined block; before then, holders can hand tokens back and get ETH. The spec also mentions consumer-protection rules such as refund periods for online purchases as motivation.\n\n## How it works\n\nThere is one extension per token standard, each detectable via [ERC-165](/eip-165/):\n\n| Extension | ERC-165 ID | `refund` takes |\n| --- | --- | --- |\n| [ERC-20](/eip-20/) Refund | `0xf0ca2917` | `amount` |\n| [ERC-721](/eip-721/) Refund | `0xe97f3c83` | `tokenId` |\n| [ERC-1155](/eip-1155/) Refund | `0x94029f5c` | `tokenId, amount` |\n\nEach has the same shape:\n\n- `refund(...)`: the caller returns their own tokens and receives ETH.\n- `refundFrom(from, ...)`: an approved operator refunds someone else's tokens; the ETH goes to `msg.sender` (useful for marketplaces or DEXs).\n- `refundOf(...)`: ETH (in wei) paid back per token, or per whole token unit for ERC-20.\n- `refundDeadlineOf(...)`: the **first block** at which refunds are no longer possible.\n- `Refund` / `RefundFrom` events.\n\nERC-721 and ERC-1155 also have optional batch versions that succeed or fail as a whole. Deadlines use block numbers rather than timestamps, which the spec considers more reliable.\n\n## Sample code\n\nA minimal refundable ERC-721 (OpenZeppelin v5), following checks-effects-interactions:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract RefundableNFT is ERC721 {\n    uint256 public constant PRICE = 0.05 ether;\n    uint256 public immutable refundDeadline;   // first block with no refunds\n    uint256 private nextId;\n\n    constructor(uint256 refundBlocks) ERC721(\"Refundable\", \"RFD\") {\n        refundDeadline = block.number + refundBlocks;\n    }\n\n    function mint() external payable {\n        require(msg.value == PRICE, \"price\");\n        _safeMint(msg.sender, nextId++);\n    }\n\n    function refundOf(uint256) external pure returns (uint256) { return PRICE; }\n    function refundDeadlineOf(uint256) external view returns (uint256) { return refundDeadline; }\n\n    function refund(uint256 tokenId) external {\n        require(block.number \u003c refundDeadline, \"refund closed\");\n        require(ownerOf(tokenId) == msg.sender, \"not owner\");\n        _burn(tokenId);                                   // effects first\n        (bool ok, ) = msg.sender.call{value: PRICE}(\"\");  // interaction last\n        require(ok, \"transfer failed\");\n    }\n    // Owner withdrawal after refundDeadline omitted for brevity.\n}\n```\n\n## Things to know\n\n- Status is **Final**.\n- Re-entrancy is the main risk: destroy or reclaim tokens **before** sending ETH.\n- `refundOf` can differ per token; a buyer who acquired tokens on a secondary market at a different price still receives the contract's refund amount.\n- The sample omits `supportsInterface`, `refundFrom` and the owner's withdrawal; production code needs all of them and an audit.\n"},"ja":{"lang":"ja","tldr":"ERC-20、ERC-721、ERC-1155 のセールに標準の返金インターフェースを追加する。購入者は期限のブロックまでトークンを返して ETH を取り戻せ、期限後は作成者がエスクローされた資金を引き出せる。","tags":["token","nft","refund","escrow"],"related":[20,721,1155,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5507/","markdown":"## 何を解決するのか\n\nトークンや NFT のローンチでは、購入者の ETH を先に受け取り、プロジェクトが消えても（「ラグプル」）救済手段がないことがよくあります。返金を約束するプロジェクトもありましたが、実装がそれぞれ異なり、ウォレットやマーケットプレイスはそれを表示することも実行することもできませんでした。\n\nERC-5507 は、初回セールの返金期間を標準化します。資金はあらかじめ決められたブロックまでエスクローに置かれ、それより前なら保有者はトークンを返して ETH を受け取れます。仕様は、オンライン購入の返金期間のような消費者保護ルールも動機として挙げています。\n\n## 仕組み\n\nトークン標準ごとに 1 つの拡張があり、それぞれ [ERC-165](/eip-165/) で検出できます。\n\n| 拡張 | ERC-165 ID | `refund` の引数 |\n| --- | --- | --- |\n| [ERC-20](/eip-20/) Refund | `0xf0ca2917` | `amount` |\n| [ERC-721](/eip-721/) Refund | `0xe97f3c83` | `tokenId` |\n| [ERC-1155](/eip-1155/) Refund | `0x94029f5c` | `tokenId, amount` |\n\nどれも同じ形をしています。\n\n- `refund(...)`: 呼び出し元が自分のトークンを返し、ETH を受け取る。\n- `refundFrom(from, ...)`: 承認されたオペレーターが他人のトークンを返金する。ETH は `msg.sender` に渡る（マーケットプレイスや DEX に便利）。\n- `refundOf(...)`: トークンごと（ERC-20 ではトークン 1 単位ごと）に払い戻される ETH（wei 単位）。\n- `refundDeadlineOf(...)`: 返金がもはやできなくなる**最初のブロック**。\n- `Refund` / `RefundFrom` イベント。\n\nERC-721 と ERC-1155 には、全体として成功か失敗かのどちらかになる任意のバッチ版もあります。期限にはタイムスタンプではなくブロック番号が使われます。仕様はこの方が信頼できると考えています。\n\n## サンプルコード\n\nchecks-effects-interactions に従った、返金可能な最小限の ERC-721（OpenZeppelin v5）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract RefundableNFT is ERC721 {\n    uint256 public constant PRICE = 0.05 ether;\n    uint256 public immutable refundDeadline;   // first block with no refunds\n    uint256 private nextId;\n\n    constructor(uint256 refundBlocks) ERC721(\"Refundable\", \"RFD\") {\n        refundDeadline = block.number + refundBlocks;\n    }\n\n    function mint() external payable {\n        require(msg.value == PRICE, \"price\");\n        _safeMint(msg.sender, nextId++);\n    }\n\n    function refundOf(uint256) external pure returns (uint256) { return PRICE; }\n    function refundDeadlineOf(uint256) external view returns (uint256) { return refundDeadline; }\n\n    function refund(uint256 tokenId) external {\n        require(block.number \u003c refundDeadline, \"refund closed\");\n        require(ownerOf(tokenId) == msg.sender, \"not owner\");\n        _burn(tokenId);                                   // effects first\n        (bool ok, ) = msg.sender.call{value: PRICE}(\"\");  // interaction last\n        require(ok, \"transfer failed\");\n    }\n    // Owner withdrawal after refundDeadline omitted for brevity.\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Final** です。\n- 主なリスクはリエントランシーです。ETH を送る**前に**トークンを破棄または回収してください。\n- `refundOf` はトークンごとに異なりえます。二次市場で別の価格でトークンを取得した購入者も、コントラクトの返金額を受け取ります。\n- このサンプルは `supportsInterface`、`refundFrom`、オーナーの引き出しを省略しています。本番コードにはそのすべてと監査が必要です。\n"},"ko":{"lang":"ko","tldr":"ERC-20, ERC-721, ERC-1155 판매에 표준 환불 인터페이스를 추가한다. 구매자는 마감 블록까지 토큰을 반환하고 ETH를 돌려받을 수 있으며, 그 이후에는 제작자가 에스크로된 자금을 청구할 수 있다.","tags":["token","nft","refund","escrow"],"related":[20,721,1155,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5507/","markdown":"## 어떤 문제를 해결하나요?\n\n토큰과 NFT 런칭은 구매자의 ETH를 먼저 받고, 프로젝트가 사라져도(\"러그 풀\") 구제 수단이 없는 경우가 많습니다. 일부 프로젝트는 환불을 약속했지만 구현 방식이 제각각이어서 지갑과 마켓플레이스가 이를 표시하거나 실행할 수 없었습니다.\n\nERC-5507은 최초 판매의 환불 기간을 표준화합니다. 자금은 미리 정한 블록까지 에스크로에 머물며, 그 전까지는 보유자가 토큰을 반환하고 ETH를 받을 수 있습니다. 명세는 온라인 구매의 환불 기간 같은 소비자 보호 규정도 동기로 언급합니다.\n\n## 어떻게 동작하나요?\n\n토큰 표준마다 확장이 하나씩 있으며, 각각 [ERC-165](/eip-165/)로 감지할 수 있습니다.\n\n| 확장 | ERC-165 ID | `refund`가 받는 인자 |\n| --- | --- | --- |\n| [ERC-20](/eip-20/) Refund | `0xf0ca2917` | `amount` |\n| [ERC-721](/eip-721/) Refund | `0xe97f3c83` | `tokenId` |\n| [ERC-1155](/eip-1155/) Refund | `0x94029f5c` | `tokenId, amount` |\n\n모두 같은 형태를 가집니다.\n\n- `refund(...)`: 호출자가 자신의 토큰을 반환하고 ETH를 받습니다.\n- `refundFrom(from, ...)`: 승인된 오퍼레이터가 다른 사람의 토큰을 환불합니다. ETH는 `msg.sender`에게 갑니다(마켓플레이스나 DEX에 유용).\n- `refundOf(...)`: 토큰당(ERC-20은 토큰 1단위당) 환급되는 ETH(wei 단위).\n- `refundDeadlineOf(...)`: 더 이상 환불이 불가능해지는 **첫 번째 블록**.\n- `Refund` / `RefundFrom` 이벤트.\n\nERC-721과 ERC-1155에는 전체가 성공하거나 전체가 실패하는 선택적 배치 버전도 있습니다. 마감은 타임스탬프가 아닌 블록 번호를 사용하며, 명세는 이쪽이 더 신뢰할 수 있다고 봅니다.\n\n## 샘플 코드\n\nchecks-effects-interactions를 따르는 최소한의 환불 가능 ERC-721(OpenZeppelin v5):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract RefundableNFT is ERC721 {\n    uint256 public constant PRICE = 0.05 ether;\n    uint256 public immutable refundDeadline;   // first block with no refunds\n    uint256 private nextId;\n\n    constructor(uint256 refundBlocks) ERC721(\"Refundable\", \"RFD\") {\n        refundDeadline = block.number + refundBlocks;\n    }\n\n    function mint() external payable {\n        require(msg.value == PRICE, \"price\");\n        _safeMint(msg.sender, nextId++);\n    }\n\n    function refundOf(uint256) external pure returns (uint256) { return PRICE; }\n    function refundDeadlineOf(uint256) external view returns (uint256) { return refundDeadline; }\n\n    function refund(uint256 tokenId) external {\n        require(block.number \u003c refundDeadline, \"refund closed\");\n        require(ownerOf(tokenId) == msg.sender, \"not owner\");\n        _burn(tokenId);                                   // effects first\n        (bool ok, ) = msg.sender.call{value: PRICE}(\"\");  // interaction last\n        require(ok, \"transfer failed\");\n    }\n    // Owner withdrawal after refundDeadline omitted for brevity.\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Final**입니다.\n- 재진입이 주요 위험입니다. ETH를 보내기 **전에** 토큰을 소각하거나 회수하세요.\n- `refundOf`는 토큰마다 다를 수 있습니다. 2차 시장에서 다른 가격으로 토큰을 취득한 구매자도 컨트랙트가 정한 환불 금액을 받습니다.\n- 이 샘플은 `supportsInterface`, `refundFrom`, 소유자의 인출을 생략했습니다. 프로덕션 코드에는 이 모두와 감사가 필요합니다.\n"},"zh":{"lang":"zh","tldr":"为 ERC-20、ERC-721 和 ERC-1155 的销售增加标准退款接口：买家可在截止区块之前退回代币换回 ETH，之后创建者可以领取托管的资金。","tags":["token","nft","refund","escrow"],"related":[20,721,1155,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5507/","markdown":"## 它解决什么问题？\n\n代币和 NFT 的发行往往先收取买家的 ETH，而一旦项目方消失（“跑路”，rug pull）就没有任何追索手段。有些项目承诺过退款，但各自实现方式不同，钱包和市场既无法展示也无法触发退款。\n\nERC-5507 为首次销售标准化了退款窗口。资金在托管中保留到预定的区块；在此之前，持有者可以退回代币并取回 ETH。规范还提到，网络购物退款期等消费者保护规则也是动机之一。\n\n## 它如何运作\n\n每种代币标准各有一个扩展，都可通过 [ERC-165](/eip-165/) 检测：\n\n| 扩展 | ERC-165 ID | `refund` 的参数 |\n| --- | --- | --- |\n| [ERC-20](/eip-20/) Refund | `0xf0ca2917` | `amount` |\n| [ERC-721](/eip-721/) Refund | `0xe97f3c83` | `tokenId` |\n| [ERC-1155](/eip-1155/) Refund | `0x94029f5c` | `tokenId, amount` |\n\n它们的结构相同：\n\n- `refund(...)`：调用者退回自己的代币并收到 ETH。\n- `refundFrom(from, ...)`：获得批准的操作者为他人退回代币；ETH 发给 `msg.sender`（对市场或 DEX 很有用）。\n- `refundOf(...)`：每个代币（ERC-20 则为每个完整代币单位）退还的 ETH（以 wei 计）。\n- `refundDeadlineOf(...)`：**第一个**不再允许退款的区块。\n- `Refund` / `RefundFrom` 事件。\n\nERC-721 和 ERC-1155 还有可选的批量版本，要么整体成功要么整体失败。截止时间使用区块号而不是时间戳，规范认为这更可靠。\n\n## 示例代码\n\n一个最小的可退款 ERC-721（OpenZeppelin v5），遵循 checks-effects-interactions：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract RefundableNFT is ERC721 {\n    uint256 public constant PRICE = 0.05 ether;\n    uint256 public immutable refundDeadline;   // first block with no refunds\n    uint256 private nextId;\n\n    constructor(uint256 refundBlocks) ERC721(\"Refundable\", \"RFD\") {\n        refundDeadline = block.number + refundBlocks;\n    }\n\n    function mint() external payable {\n        require(msg.value == PRICE, \"price\");\n        _safeMint(msg.sender, nextId++);\n    }\n\n    function refundOf(uint256) external pure returns (uint256) { return PRICE; }\n    function refundDeadlineOf(uint256) external view returns (uint256) { return refundDeadline; }\n\n    function refund(uint256 tokenId) external {\n        require(block.number \u003c refundDeadline, \"refund closed\");\n        require(ownerOf(tokenId) == msg.sender, \"not owner\");\n        _burn(tokenId);                                   // effects first\n        (bool ok, ) = msg.sender.call{value: PRICE}(\"\");  // interaction last\n        require(ok, \"transfer failed\");\n    }\n    // Owner withdrawal after refundDeadline omitted for brevity.\n}\n```\n\n## 需要注意\n\n- 状态为 **Final**。\n- 重入是主要风险：请在发送 ETH **之前**销毁或收回代币。\n- `refundOf` 可以因代币而异；在二级市场以不同价格买入代币的买家，仍然收到合约规定的退款金额。\n- 示例省略了 `supportsInterface`、`refundFrom` 和所有者的提取；生产代码需要全部实现并经过审计。\n"}}}
