{"eip":7713,"title":"Box type for EIP-712 messages","description":"A mechanism for EIP-712 messages to contain parameters of arbitrary type","authors":["Francisco Giordano (@frangio)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2024-05-23","requires":[712],"discussionsTo":"https://ethereum-magicians.org/t/eip-7713-box-types-for-eip-712-messages/20092","repo":"EIPs","label":"EIP-7713","officialUrl":"https://eips.ethereum.org/EIPS/eip-7713","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7713.md","url":"https://eips.huatuo.xyz/eip-7713/","tldr":{"en":"Proposes a box type for EIP-712 so a typed message can embed a struct of any type that the wallet can still display and type-check, instead of hiding it in opaque bytes.","ja":"EIP-712 に box 型を導入し、型付きメッセージに任意の型の構造体を埋め込めるようにする提案。不透明な bytes に隠すのではなく、ウォレットが表示と型チェックを行える状態を保てる。","ko":"EIP-712에 box 타입을 도입해, 타입이 지정된 메시지에 임의 타입의 구조체를 넣고도 지갑이 이를 표시하고 타입 검사를 할 수 있게 하자는 제안. 불투명한 bytes에 숨기지 않는다.","zh":"为 EIP-712 提出 box 类型，使类型化消息可以嵌入任意类型的结构体，并且钱包仍能显示并检查其类型，而不必把它藏在不透明的 bytes 中。"},"tags":["signing","eip712","wallets","typed-data"],"explainers":{"en":{"lang":"en","tldr":"Proposes a box type for EIP-712 so a typed message can embed a struct of any type that the wallet can still display and type-check, instead of hiding it in opaque bytes.","tags":["signing","eip712","wallets","typed-data"],"related":[712,7683,1271,7739,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7713/","markdown":"## What problem does it solve?\n\n[EIP-712](/eip-712/) lets wallets show users exactly what they are signing, field by field. That transparency breaks down when a standard message needs to carry *implementation-specific* data of unknown type. The usual workaround is a `bytes` field, which wallets can only show as a hex blob.\n\nThe spec gives two examples:\n\n- [ERC-7683](/eip-7683/) cross-chain orders had a `bytes orderData` field, so users signed opaque data.\n- Making [ERC-1271](/eip-1271/) smart-account signatures replay-safe means wrapping an app's EIP-712 message inside an outer message bound to the account (the approach taken by [ERC-7739](/eip-7739/), itself a Draft). The outer type depends on the inner type, which today requires shipping the inner type string inside the signature.\n\nA `box` type lets the outer struct stay generic while the inner struct remains fully visible to the wallet.\n\n## How it works\n\n- A struct member can be declared with type `box`, e.g. `struct Envelope { address account; box contents; }`.\n- **encodeType**: a boxed member is written as `box \u003cname\u003e`, so the outer type is `Envelope(address account,box contents)` regardless of what is inside. The verifying contract can therefore be agnostic to the inner type.\n- **encodeData**: a boxed value is encoded as the `hashStruct` of the underlying (unboxed) value, using that value's own type hash. The inner type is not erased; a contract can still verify it if needed.\n- **signTypedData JSON**: a boxed value is an object with `primaryType`, `types` and `value`. Types defined in the outer message are not in scope inside the box, so each box is self-describing.\n\n## Sample code\n\nAn `eth_signTypedData_v4`-style request using a box (from the spec's example):\n\n```json\n{\n  \"domain\": { \"name\": \"MyAccount\", \"version\": \"1\", \"chainId\": 1 },\n  \"primaryType\": \"Envelope\",\n  \"types\": {\n    \"Envelope\": [\n      { \"name\": \"account\", \"type\": \"address\" },\n      { \"name\": \"contents\", \"type\": \"box\" }\n    ]\n  },\n  \"message\": {\n    \"account\": \"0x0000000000000000000000000000000000000001\",\n    \"contents\": {\n      \"primaryType\": \"Mail\",\n      \"types\": { \"Mail\": [{ \"name\": \"greeting\", \"type\": \"string\" }] },\n      \"value\": { \"greeting\": \"Hello world\" }\n    }\n  }\n}\n```\n\nHow the hash is built (pseudocode):\n\n```python\nENVELOPE_TYPEHASH = keccak256(\"Envelope(address account,box contents)\")\nMAIL_TYPEHASH     = keccak256(\"Mail(string greeting)\")\n\ncontents_hash = keccak256(MAIL_TYPEHASH + keccak256(\"Hello world\"))  # hashStruct of the unboxed value\nenvelope_hash = keccak256(ENVELOPE_TYPEHASH + pad32(account) + contents_hash)\n```\n\n## Things to know\n\n- **Status: Stagnant.** The Rationale and Security Considerations sections are still marked TBD / \"needs discussion\", and `box` is not part of EIP-712 itself, so a wallet that has not implemented this extension should be expected to reject such a request.\n- Because the outer type string is the same for every inner type, a contract that does not check the inner type hash accepts *any* boxed struct. Contracts that care about the content must verify it explicitly.\n- If you need replay-safe smart-account signatures now, look at [ERC-7739](/eip-7739/) (Draft), which tackles the nested-message case without changing EIP-712.\n"},"ja":{"lang":"ja","tldr":"EIP-712 に box 型を導入し、型付きメッセージに任意の型の構造体を埋め込めるようにする提案。不透明な bytes に隠すのではなく、ウォレットが表示と型チェックを行える状態を保てる。","tags":["signing","eip712","wallets","typed-data"],"related":[712,7683,1271,7739,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7713/","markdown":"## 何を解決するのか\n\n[EIP-712](/eip-712/) により、ウォレットはユーザーが署名する内容をフィールドごとに正確に表示できます。しかし、標準的なメッセージが型の不明な*実装固有*のデータを運ぶ必要がある場合、この透明性は崩れます。よくある回避策は `bytes` フィールドですが、ウォレットは 16 進数の塊としてしか表示できません。\n\n仕様では 2 つの例が挙げられています。\n\n- [ERC-7683](/eip-7683/) のクロスチェーンオーダーには `bytes orderData` フィールドがあり、ユーザーは不透明なデータに署名していました。\n- [ERC-1271](/eip-1271/) のスマートアカウント署名をリプレイ耐性のあるものにするには、アプリの EIP-712 メッセージを、アカウントに紐づく外側のメッセージで包む必要があります（[ERC-7739](/eip-7739/) が採る方式で、これ自体も Draft です）。外側の型は内側の型に依存するため、現状では内側の型文字列を署名に含めて送る必要があります。\n\n`box` 型を使えば、外側の構造体は汎用のままで、内側の構造体はウォレットから完全に見える状態を保てます。\n\n## 仕組み\n\n- 構造体のメンバーは `box` 型として宣言できます。例: `struct Envelope { address account; box contents; }`。\n- **encodeType**: box 化されたメンバーは `box \u003cname\u003e` と書かれるため、中身が何であっても外側の型は `Envelope(address account,box contents)` になります。したがって、検証側のコントラクトは内側の型に依存せずに済みます。\n- **encodeData**: box 化された値は、その（box を外した）値自身の型ハッシュを使った `hashStruct` としてエンコードされます。内側の型は消去されないため、必要であればコントラクトが検証できます。\n- **signTypedData JSON**: box 化された値は `primaryType`、`types`、`value` を持つオブジェクトです。外側のメッセージで定義された型は box の中では参照できないため、各 box は自己記述的です。\n\n## サンプルコード\n\nbox を使った `eth_signTypedData_v4` 形式のリクエスト（仕様の例より）:\n\n```json\n{\n  \"domain\": { \"name\": \"MyAccount\", \"version\": \"1\", \"chainId\": 1 },\n  \"primaryType\": \"Envelope\",\n  \"types\": {\n    \"Envelope\": [\n      { \"name\": \"account\", \"type\": \"address\" },\n      { \"name\": \"contents\", \"type\": \"box\" }\n    ]\n  },\n  \"message\": {\n    \"account\": \"0x0000000000000000000000000000000000000001\",\n    \"contents\": {\n      \"primaryType\": \"Mail\",\n      \"types\": { \"Mail\": [{ \"name\": \"greeting\", \"type\": \"string\" }] },\n      \"value\": { \"greeting\": \"Hello world\" }\n    }\n  }\n}\n```\n\nハッシュの組み立て方（擬似コード）:\n\n```python\nENVELOPE_TYPEHASH = keccak256(\"Envelope(address account,box contents)\")\nMAIL_TYPEHASH     = keccak256(\"Mail(string greeting)\")\n\ncontents_hash = keccak256(MAIL_TYPEHASH + keccak256(\"Hello world\"))  # hashStruct of the unboxed value\nenvelope_hash = keccak256(ENVELOPE_TYPEHASH + pad32(account) + contents_hash)\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** Rationale と Security Considerations のセクションは依然として TBD /「要議論」とされており、`box` は EIP-712 自体の一部ではありません。この拡張を実装していないウォレットは、こうしたリクエストを拒否するものと考えてください。\n- 外側の型文字列はどの内側の型でも同じなので、内側の型ハッシュを確認しないコントラクトは*あらゆる* box 化された構造体を受け入れてしまいます。内容が重要なコントラクトは、明示的に検証する必要があります。\n- リプレイ耐性のあるスマートアカウント署名が今すぐ必要なら、EIP-712 を変更せずに入れ子メッセージの問題に取り組む [ERC-7739](/eip-7739/)（Draft）を参照してください。\n"},"ko":{"lang":"ko","tldr":"EIP-712에 box 타입을 도입해, 타입이 지정된 메시지에 임의 타입의 구조체를 넣고도 지갑이 이를 표시하고 타입 검사를 할 수 있게 하자는 제안. 불투명한 bytes에 숨기지 않는다.","tags":["signing","eip712","wallets","typed-data"],"related":[712,7683,1271,7739,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7713/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-712](/eip-712/)는 지갑이 사용자가 서명하는 내용을 필드 단위로 정확히 보여 줄 수 있게 합니다. 그런데 표준 메시지가 타입을 알 수 없는 *구현별* 데이터를 실어 날라야 하면 이런 투명성이 무너집니다. 흔한 우회책은 `bytes` 필드인데, 지갑은 이를 16진수 덩어리로만 보여 줄 수 있습니다.\n\n스펙은 두 가지 예를 듭니다.\n\n- [ERC-7683](/eip-7683/) 크로스체인 주문에는 `bytes orderData` 필드가 있어서 사용자가 불투명한 데이터에 서명했습니다.\n- [ERC-1271](/eip-1271/) 스마트 계정 서명을 리플레이에 안전하게 만들려면, 앱의 EIP-712 메시지를 계정에 묶인 바깥쪽 메시지로 감싸야 합니다([ERC-7739](/eip-7739/)가 택한 방식이며, 이것도 Draft입니다). 바깥쪽 타입이 안쪽 타입에 의존하므로, 현재는 안쪽 타입 문자열을 서명에 함께 실어 보내야 합니다.\n\n`box` 타입을 쓰면 바깥쪽 구조체는 범용으로 유지하면서 안쪽 구조체는 지갑에 완전히 보이는 상태로 남습니다.\n\n## 어떻게 동작하나요?\n\n- 구조체 멤버를 `box` 타입으로 선언할 수 있습니다. 예: `struct Envelope { address account; box contents; }`.\n- **encodeType**: box된 멤버는 `box \u003cname\u003e`으로 표기되므로, 안에 무엇이 있든 바깥쪽 타입은 `Envelope(address account,box contents)`입니다. 따라서 검증하는 컨트랙트는 안쪽 타입을 몰라도 됩니다.\n- **encodeData**: box된 값은 그 (box를 벗긴) 값 자신의 타입 해시를 사용한 `hashStruct`로 인코딩됩니다. 안쪽 타입은 지워지지 않으므로 필요하면 컨트랙트가 여전히 검증할 수 있습니다.\n- **signTypedData JSON**: box된 값은 `primaryType`, `types`, `value`를 가진 객체입니다. 바깥쪽 메시지에서 정의한 타입은 box 안에서 유효하지 않으므로, 각 box는 스스로를 설명합니다.\n\n## 샘플 코드\n\nbox를 사용하는 `eth_signTypedData_v4` 스타일 요청(스펙의 예시):\n\n```json\n{\n  \"domain\": { \"name\": \"MyAccount\", \"version\": \"1\", \"chainId\": 1 },\n  \"primaryType\": \"Envelope\",\n  \"types\": {\n    \"Envelope\": [\n      { \"name\": \"account\", \"type\": \"address\" },\n      { \"name\": \"contents\", \"type\": \"box\" }\n    ]\n  },\n  \"message\": {\n    \"account\": \"0x0000000000000000000000000000000000000001\",\n    \"contents\": {\n      \"primaryType\": \"Mail\",\n      \"types\": { \"Mail\": [{ \"name\": \"greeting\", \"type\": \"string\" }] },\n      \"value\": { \"greeting\": \"Hello world\" }\n    }\n  }\n}\n```\n\n해시를 만드는 방식(의사 코드):\n\n```python\nENVELOPE_TYPEHASH = keccak256(\"Envelope(address account,box contents)\")\nMAIL_TYPEHASH     = keccak256(\"Mail(string greeting)\")\n\ncontents_hash = keccak256(MAIL_TYPEHASH + keccak256(\"Hello world\"))  # hashStruct of the unboxed value\nenvelope_hash = keccak256(ENVELOPE_TYPEHASH + pad32(account) + contents_hash)\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** Rationale과 Security Considerations 섹션은 여전히 TBD / \"논의 필요\"로 표시되어 있고, `box`는 EIP-712 자체에 포함되어 있지 않습니다. 따라서 이 확장을 구현하지 않은 지갑은 이런 요청을 거부할 것으로 예상해야 합니다.\n- 바깥쪽 타입 문자열은 안쪽 타입과 상관없이 모두 같으므로, 안쪽 타입 해시를 확인하지 않는 컨트랙트는 *어떤* box된 구조체든 받아들입니다. 내용이 중요한 컨트랙트는 이를 명시적으로 검증해야 합니다.\n- 리플레이에 안전한 스마트 계정 서명이 지금 필요하다면, EIP-712를 바꾸지 않고 중첩 메시지 문제를 다루는 [ERC-7739](/eip-7739/)(Draft)를 살펴보세요.\n"},"zh":{"lang":"zh","tldr":"为 EIP-712 提出 box 类型，使类型化消息可以嵌入任意类型的结构体，并且钱包仍能显示并检查其类型，而不必把它藏在不透明的 bytes 中。","tags":["signing","eip712","wallets","typed-data"],"related":[712,7683,1271,7739,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7713/","markdown":"## 它解决什么问题？\n\n[EIP-712](/eip-712/) 让钱包能逐个字段地向用户展示他们正在签署的内容。但当标准消息需要携带类型未知的*实现特定*数据时，这种透明性就被破坏了。常见的变通做法是使用 `bytes` 字段，而钱包只能把它显示为一串十六进制。\n\n规范给出了两个例子：\n\n- [ERC-7683](/eip-7683/) 的跨链订单有一个 `bytes orderData` 字段，因此用户签署的是不透明数据。\n- 要让 [ERC-1271](/eip-1271/) 智能账户签名具备重放安全性，就需要把应用的 EIP-712 消息包进一个与账户绑定的外层消息中（这是 [ERC-7739](/eip-7739/) 采用的方式，它本身也是 Draft）。外层类型取决于内层类型，而目前这要求把内层类型字符串随签名一起提供。\n\n`box` 类型让外层结构体保持通用，同时内层结构体对钱包仍然完全可见。\n\n## 它如何运作\n\n- 结构体成员可以声明为 `box` 类型，例如 `struct Envelope { address account; box contents; }`。\n- **encodeType**：被 box 的成员写作 `box \u003cname\u003e`，因此无论里面是什么，外层类型都是 `Envelope(address account,box contents)`。验证合约因此可以不关心内层类型。\n- **encodeData**：被 box 的值会编码为底层（未 box）值的 `hashStruct`，使用该值自己的类型哈希。内层类型并没有被擦除；合约在需要时仍可以验证它。\n- **signTypedData JSON**：被 box 的值是一个带有 `primaryType`、`types` 和 `value` 的对象。外层消息中定义的类型在 box 内部不可见，因此每个 box 都是自描述的。\n\n## 示例代码\n\n使用 box 的 `eth_signTypedData_v4` 风格请求（来自规范的示例）：\n\n```json\n{\n  \"domain\": { \"name\": \"MyAccount\", \"version\": \"1\", \"chainId\": 1 },\n  \"primaryType\": \"Envelope\",\n  \"types\": {\n    \"Envelope\": [\n      { \"name\": \"account\", \"type\": \"address\" },\n      { \"name\": \"contents\", \"type\": \"box\" }\n    ]\n  },\n  \"message\": {\n    \"account\": \"0x0000000000000000000000000000000000000001\",\n    \"contents\": {\n      \"primaryType\": \"Mail\",\n      \"types\": { \"Mail\": [{ \"name\": \"greeting\", \"type\": \"string\" }] },\n      \"value\": { \"greeting\": \"Hello world\" }\n    }\n  }\n}\n```\n\n哈希的构造方式（伪代码）：\n\n```python\nENVELOPE_TYPEHASH = keccak256(\"Envelope(address account,box contents)\")\nMAIL_TYPEHASH     = keccak256(\"Mail(string greeting)\")\n\ncontents_hash = keccak256(MAIL_TYPEHASH + keccak256(\"Hello world\"))  # hashStruct of the unboxed value\nenvelope_hash = keccak256(ENVELOPE_TYPEHASH + pad32(account) + contents_hash)\n```\n\n## 需要注意\n\n- **状态：Stagnant。** Rationale 和 Security Considerations 部分仍标注为 TBD / \"需要讨论\"，而且 `box` 并不属于 EIP-712 本身，因此没有实现该扩展的钱包很可能会拒绝这类请求。\n- 由于外层类型字符串对每种内层类型都相同，不检查内层类型哈希的合约会接受*任何* box 化的结构体。关心内容的合约必须显式验证它。\n- 如果你现在就需要具备重放安全性的智能账户签名，请看 [ERC-7739](/eip-7739/)（Draft），它在不修改 EIP-712 的前提下解决了嵌套消息的问题。\n"}}}
