{"eip":5750,"title":"General Extensibility for Method Behaviors","description":"Designating last param of dynamically sized bytes to be used for behavior extensions of methods.","authors":["Zainan Victor Zhou (@xinbenlv)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2022-10-04","requires":[165],"discussionsTo":"https://ethereum-magicians.org/t/erc-5750-method-with-extra-data/11176","repo":"ERCs","label":"ERC-5750","officialUrl":"https://eips.ethereum.org/EIPS/eip-5750","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5750.md","url":"https://eips.huatuo.xyz/eip-5750/","tldr":{"en":"A convention that a method's last bytes parameter is reserved for future behaviour extensions, and that passing empty bytes must behave exactly like the overload without it.","ja":"メソッドの最後の bytes パラメーターを将来の振る舞いの拡張用に予約し、空の bytes を渡したときは、それを持たないオーバーロードとまったく同じ動作をするべきという規約。","ko":"메서드의 마지막 bytes 파라미터를 향후 동작 확장용으로 예약하고, 빈 bytes를 전달하면 그 파라미터가 없는 오버로드와 완전히 똑같이 동작해야 한다는 관례.","zh":"一项约定：方法的最后一个 bytes 参数保留用于未来的行为扩展，并且传入空 bytes 时，其行为必须与不带该参数的重载完全一致。"},"tags":["interface","extensibility","calldata","convention"],"explainers":{"en":{"lang":"en","tldr":"A convention that a method's last bytes parameter is reserved for future behaviour extensions, and that passing empty bytes must behave exactly like the overload without it.","tags":["interface","extensibility","calldata","convention"],"related":[721,1155,777,5732,1271],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5750/","markdown":"## What problem does it solve?\n\nOnce an interface ships, adding features is awkward. You either invent a new method (new name, new parameters, new integration work) or try to squeeze extra meaning into existing parameters. Neither scales well when you later want to attach a signature, a nonce, a salt, a commitment, or a human-readable reason to a call.\n\nERC-5750 standardises a simple escape hatch: a trailing `bytes` parameter that is explicitly reserved for extensions. Several existing standards already have this shape, so the ERC mostly gives a name and a rule to an existing habit.\n\n## How it works\n\nCompliance is defined **per method**, not per contract:\n\n1. A method whose **last parameter is `bytes`** is *eligible*:\n   `function methodName(type1 a, type2 b, ..., bytes data)`.\n2. A method is *compliant* if it is eligible **and** that last `bytes` is designated for behaviour extensions (not used for its core function).\n3. If the method has an overloaded sibling with the same name and same leading parameters but without the `bytes`, then calling the compliant version with **empty bytes must behave identically** to the sibling.\n\nExamples from the spec of methods that already comply:\n\n- [ERC-721](/eip-721/) `safeTransferFrom(from, to, tokenId, bytes data)`\n- [ERC-1155](/eip-1155/) `safeTransferFrom(...)` and `safeBatchTransferFrom(...)`\n- [ERC-777](/eip-777/) `send(to, amount, data)` and `burn(amount, data)`\n\nAnd methods that do **not** comply, because their trailing `bytes` is load-bearing:\n\n- [ERC-1271](/eip-1271/) `isValidSignature(bytes32 hash, bytes signature)`: the bytes *is* the signature.\n- ERC-2535 `diamondCut(..., bytes _calldata)`: the bytes is the init call.\n\nThese could become compliant by adding an overload with an extra trailing `bytes data`.\n\nPutting the field last keeps it compatible with Solidity's ABI layout, and `bytes` can carry any encoded payload.\n\n## Sample code\n\nA vote function with an extension slot. Empty `data` behaves like the plain overload; non-empty `data` carries an optional reason:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Ballot {\n    event Voted(address indexed voter, uint256 proposal, string reason);\n    mapping(address =\u003e bool) public hasVoted;\n\n    // Sibling without extension data\n    function vote(uint256 proposal) external {\n        _vote(proposal, \"\");\n    }\n\n    // ERC-5750 compliant: last bytes param is for extensions.\n    // With data.length == 0 it MUST behave exactly like vote(proposal).\n    function vote(uint256 proposal, bytes calldata data) external {\n        string memory reason = data.length == 0 ? \"\" : abi.decode(data, (string));\n        _vote(proposal, reason);\n    }\n\n    function _vote(uint256 proposal, string memory reason) internal {\n        require(!hasVoted[msg.sender], \"already voted\");\n        hasVoted[msg.sender] = true;\n        emit Voted(msg.sender, proposal, reason);\n    }\n}\n```\n\nCalling it from ethers v6 (overloaded functions need the full signature):\n\n```ts\nimport { AbiCoder } from \"ethers\";\nconst data = AbiCoder.defaultAbiCoder().encode([\"string\"], [\"Supports the roadmap\"]);\nawait ballot[\"vote(uint256,bytes)\"](1n, data);\n```\n\n## Things to know\n\n- **Status: Final.**\n- The ERC defines *where* extension data goes, not *what* it contains. Each extension (signatures, commit-reveal as in [ERC-5732](/eip-5732/), etc.) must define its own encoding and follow its own security practices.\n- Anything in `data` is public once it hits the mempool. The spec warns against putting unencrypted personal information there and reminds implementers to consider replay and front-running.\n- The \"empty bytes equals the sibling\" rule is what makes the pattern safe for existing integrators; breaking it makes the method non-compliant.\n"},"ja":{"lang":"ja","tldr":"メソッドの最後の bytes パラメーターを将来の振る舞いの拡張用に予約し、空の bytes を渡したときは、それを持たないオーバーロードとまったく同じ動作をするべきという規約。","tags":["interface","extensibility","calldata","convention"],"related":[721,1155,777,5732,1271],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5750/","markdown":"## 何を解決するのか\n\nインターフェースが公開されると、機能の追加は厄介です。新しいメソッド（新しい名前、新しいパラメーター、新しい連携作業）を考案するか、既存のパラメーターに余分な意味を詰め込むかのどちらかです。後から署名、nonce、salt、コミットメント、人が読める理由を呼び出しに添えたくなったとき、どちらもうまくスケールしません。\n\nERC-5750 は、シンプルな逃げ道を標準化します。拡張用に明示的に予約された、末尾の `bytes` パラメーターです。既存の標準のいくつかはすでにこの形をしているため、この ERC は主に、既存の習慣に名前とルールを与えるものです。\n\n## 仕組み\n\n準拠性は、コントラクト単位ではなく**メソッド単位**で定義されます。\n\n1. **最後のパラメーターが `bytes`** であるメソッドは*対象となり得ます*:\n   `function methodName(type1 a, type2 b, ..., bytes data)`。\n2. メソッドが対象となり得て、**かつ**その最後の `bytes` が振る舞いの拡張用に指定されている（中核的な機能には使われない）場合、そのメソッドは*準拠*しています。\n3. 同じ名前で先頭のパラメーターが同じ、`bytes` のないオーバーロードの兄弟メソッドがある場合、準拠版を**空の bytes で呼び出したときは、その兄弟とまったく同じ動作をしなければなりません**。\n\nすでに準拠しているメソッドの、仕様にある例:\n\n- [ERC-721](/eip-721/) の `safeTransferFrom(from, to, tokenId, bytes data)`\n- [ERC-1155](/eip-1155/) の `safeTransferFrom(...)` と `safeBatchTransferFrom(...)`\n- [ERC-777](/eip-777/) の `send(to, amount, data)` と `burn(amount, data)`\n\nそして、末尾の `bytes` が機能の中核を担っているため、準拠**しない**メソッド:\n\n- [ERC-1271](/eip-1271/) の `isValidSignature(bytes32 hash, bytes signature)`: この bytes は署名*そのもの*です。\n- ERC-2535 の `diamondCut(..., bytes _calldata)`: この bytes は初期化呼び出しです。\n\nこれらは、末尾に `bytes data` を加えたオーバーロードを追加すれば、準拠させることができます。\n\nフィールドを最後に置くことで Solidity の ABI レイアウトとの互換性が保たれ、`bytes` はあらゆるエンコード済みペイロードを運べます。\n\n## サンプルコード\n\n拡張用スロットを持つ投票関数です。空の `data` は通常のオーバーロードと同じ動作をし、空でない `data` は任意の理由を運びます。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Ballot {\n    event Voted(address indexed voter, uint256 proposal, string reason);\n    mapping(address =\u003e bool) public hasVoted;\n\n    // Sibling without extension data\n    function vote(uint256 proposal) external {\n        _vote(proposal, \"\");\n    }\n\n    // ERC-5750 compliant: last bytes param is for extensions.\n    // With data.length == 0 it MUST behave exactly like vote(proposal).\n    function vote(uint256 proposal, bytes calldata data) external {\n        string memory reason = data.length == 0 ? \"\" : abi.decode(data, (string));\n        _vote(proposal, reason);\n    }\n\n    function _vote(uint256 proposal, string memory reason) internal {\n        require(!hasVoted[msg.sender], \"already voted\");\n        hasVoted[msg.sender] = true;\n        emit Voted(msg.sender, proposal, reason);\n    }\n}\n```\n\nethers v6 からの呼び出し（オーバーロードされた関数には完全なシグネチャが必要です）:\n\n```ts\nimport { AbiCoder } from \"ethers\";\nconst data = AbiCoder.defaultAbiCoder().encode([\"string\"], [\"Supports the roadmap\"]);\nawait ballot[\"vote(uint256,bytes)\"](1n, data);\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final。**\n- この ERC が定義するのは、拡張データを*どこに*置くかであり、*何を*含めるかではありません。各拡張（署名、[ERC-5732](/eip-5732/) のようなコミット・リビールなど）は、独自のエンコーディングを定義し、独自のセキュリティ上の慣行に従う必要があります。\n- `data` の中身は、mempool に載った時点で公開されます。仕様は、暗号化されていない個人情報をそこに入れないよう警告し、実装者にリプレイやフロントランニングを考慮するよう注意を促しています。\n- 「空の bytes は兄弟メソッドと同じ」というルールが、このパターンを既存の連携先にとって安全なものにしています。これを破ると、そのメソッドは準拠しなくなります。\n"},"ko":{"lang":"ko","tldr":"메서드의 마지막 bytes 파라미터를 향후 동작 확장용으로 예약하고, 빈 bytes를 전달하면 그 파라미터가 없는 오버로드와 완전히 똑같이 동작해야 한다는 관례.","tags":["interface","extensibility","calldata","convention"],"related":[721,1155,777,5732,1271],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5750/","markdown":"## 어떤 문제를 해결하나요?\n\n인터페이스가 배포되고 나면 기능을 추가하기가 곤란합니다. 새 메서드(새 이름, 새 파라미터, 새 연동 작업)를 만들거나, 기존 파라미터에 추가 의미를 욱여넣어야 합니다. 나중에 호출에 서명, nonce, salt, 커밋먼트, 사람이 읽을 수 있는 사유를 붙이고 싶어질 때 둘 다 확장성이 좋지 않습니다.\n\nERC-5750은 간단한 탈출구를 표준화합니다. 확장용으로 명시적으로 예약된 마지막 `bytes` 파라미터입니다. 이미 여러 기존 표준이 이런 형태를 갖고 있으므로, 이 ERC는 대체로 기존 관행에 이름과 규칙을 붙여주는 셈입니다.\n\n## 어떻게 동작하나요?\n\n준수 여부는 컨트랙트 단위가 아니라 **메서드 단위**로 정의됩니다.\n\n1. **마지막 파라미터가 `bytes`**인 메서드는 *자격이 있습니다*:\n   `function methodName(type1 a, type2 b, ..., bytes data)`.\n2. 메서드가 자격이 있고 **그리고** 마지막 `bytes`가 동작 확장용으로 지정되어 있다면(핵심 기능에 쓰이지 않는다면) 그 메서드는 *준수*합니다.\n3. 같은 이름에 앞쪽 파라미터가 같고 `bytes`가 없는 오버로드 형제 메서드가 있다면, 준수하는 버전을 **빈 bytes로 호출했을 때 그 형제 메서드와 완전히 똑같이 동작해야 합니다**.\n\n이미 준수하는 메서드의 사양 속 예시입니다.\n\n- [ERC-721](/eip-721/)의 `safeTransferFrom(from, to, tokenId, bytes data)`\n- [ERC-1155](/eip-1155/)의 `safeTransferFrom(...)`과 `safeBatchTransferFrom(...)`\n- [ERC-777](/eip-777/)의 `send(to, amount, data)`와 `burn(amount, data)`\n\n그리고 마지막 `bytes`가 핵심 역할을 하기 때문에 준수하지 **않는** 메서드입니다.\n\n- [ERC-1271](/eip-1271/)의 `isValidSignature(bytes32 hash, bytes signature)`: 이 bytes는 서명 *그 자체*입니다.\n- ERC-2535의 `diamondCut(..., bytes _calldata)`: 이 bytes는 초기화 호출입니다.\n\n이들은 마지막에 `bytes data`가 추가된 오버로드를 더하면 준수하게 될 수 있습니다.\n\n필드를 마지막에 두면 Solidity의 ABI 레이아웃과 호환되며, `bytes`는 어떤 인코딩된 페이로드든 담을 수 있습니다.\n\n## 샘플 코드\n\n확장 슬롯이 있는 투표 함수입니다. 빈 `data`는 기본 오버로드처럼 동작하고, 비어 있지 않은 `data`는 선택적 사유를 담습니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Ballot {\n    event Voted(address indexed voter, uint256 proposal, string reason);\n    mapping(address =\u003e bool) public hasVoted;\n\n    // Sibling without extension data\n    function vote(uint256 proposal) external {\n        _vote(proposal, \"\");\n    }\n\n    // ERC-5750 compliant: last bytes param is for extensions.\n    // With data.length == 0 it MUST behave exactly like vote(proposal).\n    function vote(uint256 proposal, bytes calldata data) external {\n        string memory reason = data.length == 0 ? \"\" : abi.decode(data, (string));\n        _vote(proposal, reason);\n    }\n\n    function _vote(uint256 proposal, string memory reason) internal {\n        require(!hasVoted[msg.sender], \"already voted\");\n        hasVoted[msg.sender] = true;\n        emit Voted(msg.sender, proposal, reason);\n    }\n}\n```\n\nethers v6에서 호출하는 방법입니다(오버로드된 함수에는 전체 시그니처가 필요합니다).\n\n```ts\nimport { AbiCoder } from \"ethers\";\nconst data = AbiCoder.defaultAbiCoder().encode([\"string\"], [\"Supports the roadmap\"]);\nawait ballot[\"vote(uint256,bytes)\"](1n, data);\n```\n\n## 알아둘 점\n\n- **상태: Final.**\n- 이 ERC는 확장 데이터가 *어디에* 들어가는지를 정의할 뿐, *무엇을* 담는지는 정의하지 않습니다. 각 확장(서명, [ERC-5732](/eip-5732/)의 커밋-리빌 등)은 자체 인코딩을 정의하고 자체 보안 관행을 따라야 합니다.\n- `data`에 담긴 내용은 멤풀에 올라가는 순간 공개됩니다. 사양은 암호화되지 않은 개인 정보를 넣지 말라고 경고하고, 구현자에게 리플레이와 프런트러닝을 고려하라고 상기시킵니다.\n- \"빈 bytes는 형제 메서드와 같다\"는 규칙이 이 패턴을 기존 연동 쪽에 안전하게 만듭니다. 이를 깨면 그 메서드는 준수하지 않게 됩니다.\n"},"zh":{"lang":"zh","tldr":"一项约定：方法的最后一个 bytes 参数保留用于未来的行为扩展，并且传入空 bytes 时，其行为必须与不带该参数的重载完全一致。","tags":["interface","extensibility","calldata","convention"],"related":[721,1155,777,5732,1271],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5750/","markdown":"## 它解决什么问题？\n\n接口一旦发布，添加功能就会很尴尬。你要么发明一个新方法（新名称、新参数、新的集成工作），要么试图给现有参数塞进额外含义。当你之后想给调用附加签名、nonce、salt、承诺或人类可读的理由时，这两种办法都难以扩展。\n\nERC-5750 规范了一个简单的出口：一个明确保留给扩展的末尾 `bytes` 参数。若干现有标准已经具有这种形态，因此该 ERC 主要是给一个已有的习惯赋予名称和规则。\n\n## 它如何运作\n\n合规性按**方法**而不是按合约来定义：\n\n1. **最后一个参数是 `bytes`** 的方法*有资格*：\n   `function methodName(type1 a, type2 b, ..., bytes data)`。\n2. 如果方法有资格，**并且**最后那个 `bytes` 被指定用于行为扩展（而不是用于其核心功能），则该方法是*合规*的。\n3. 如果该方法有一个同名、前面参数相同但不带 `bytes` 的重载兄弟方法，那么以**空 bytes 调用合规版本时，其行为必须与该兄弟方法完全相同**。\n\n规范中已经合规的方法示例：\n\n- [ERC-721](/eip-721/) 的 `safeTransferFrom(from, to, tokenId, bytes data)`\n- [ERC-1155](/eip-1155/) 的 `safeTransferFrom(...)` 和 `safeBatchTransferFrom(...)`\n- [ERC-777](/eip-777/) 的 `send(to, amount, data)` 和 `burn(amount, data)`\n\n以及**不**合规的方法，因为它们末尾的 `bytes` 承担着核心作用：\n\n- [ERC-1271](/eip-1271/) 的 `isValidSignature(bytes32 hash, bytes signature)`：这个 bytes *就是*签名。\n- ERC-2535 的 `diamondCut(..., bytes _calldata)`：这个 bytes 是初始化调用。\n\n这些方法可以通过增加一个带有额外末尾 `bytes data` 的重载而变得合规。\n\n把该字段放在最后，可以保持与 Solidity ABI 布局的兼容，并且 `bytes` 可以承载任何编码后的负载。\n\n## 示例代码\n\n一个带有扩展槽的投票函数。空的 `data` 与普通重载行为一致；非空的 `data` 携带一个可选的理由：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Ballot {\n    event Voted(address indexed voter, uint256 proposal, string reason);\n    mapping(address =\u003e bool) public hasVoted;\n\n    // Sibling without extension data\n    function vote(uint256 proposal) external {\n        _vote(proposal, \"\");\n    }\n\n    // ERC-5750 compliant: last bytes param is for extensions.\n    // With data.length == 0 it MUST behave exactly like vote(proposal).\n    function vote(uint256 proposal, bytes calldata data) external {\n        string memory reason = data.length == 0 ? \"\" : abi.decode(data, (string));\n        _vote(proposal, reason);\n    }\n\n    function _vote(uint256 proposal, string memory reason) internal {\n        require(!hasVoted[msg.sender], \"already voted\");\n        hasVoted[msg.sender] = true;\n        emit Voted(msg.sender, proposal, reason);\n    }\n}\n```\n\n从 ethers v6 调用（重载函数需要完整签名）：\n\n```ts\nimport { AbiCoder } from \"ethers\";\nconst data = AbiCoder.defaultAbiCoder().encode([\"string\"], [\"Supports the roadmap\"]);\nawait ballot[\"vote(uint256,bytes)\"](1n, data);\n```\n\n## 需要注意\n\n- **状态：Final。**\n- 该 ERC 定义的是扩展数据放*在哪里*，而不是其中包含*什么*。每个扩展（签名、如 [ERC-5732](/eip-5732/) 中的提交-揭示等）必须定义自己的编码，并遵循自己的安全实践。\n- `data` 中的任何内容一旦进入内存池就是公开的。规范警告不要在其中放入未加密的个人信息，并提醒实现者考虑重放和抢跑问题。\n- \"空 bytes 等同于兄弟方法\"这条规则，使该模式对现有集成方是安全的；打破它会使该方法不再合规。\n"}},"requiredBy":[5269,5453,5982,6066,6224]}
