{"eip":7786,"title":"Cross-Chain Messaging Gateway","description":"An interface for contracts to send and receive cross-chain messages containing arbitrary data.","authors":["Francisco Giordano (@frangio)","Hadrien Croubois (@Amxx)","Ernesto García (@ernestognw)","CJ Cobb (@cjcobb23)","Sergey Gorbunov (@sergeynog)","joxes (@Joxess)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2024-10-14","requires":[7930],"discussionsTo":"https://ethereum-magicians.org/t/erc-7786-cross-chain-messaging-gateway/21374","repo":"ERCs","label":"ERC-7786","officialUrl":"https://eips.ethereum.org/EIPS/eip-7786","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7786.md","url":"https://eips.huatuo.xyz/eip-7786/","tldr":{"en":"One gateway interface for sending and receiving arbitrary cross-chain messages, so contracts can talk across chains through any bridge (natively or via adapters) without locking into a single vendor's API.","ja":"任意のクロスチェーンメッセージを送受信するための単一のゲートウェイインターフェース。コントラクトが、特定ベンダーの API に縛られることなく、（ネイティブまたはアダプター経由で）あらゆるブリッジを通じてチェーン間で通信できる。","ko":"임의의 크로스체인 메시지를 보내고 받기 위한 단일 게이트웨이 인터페이스. 컨트랙트가 특정 벤더의 API에 묶이지 않고 (네이티브 또는 어댑터를 통해) 어떤 브리지로든 체인 간에 통신할 수 있게 한다.","zh":"用于发送和接收任意跨链消息的统一网关接口，使合约可以通过任何桥（原生或通过适配器）跨链通信，而不会被锁定在单一厂商的 API 上。"},"tags":["cross-chain","bridges","messaging","interoperability"],"explainers":{"en":{"lang":"en","tldr":"One gateway interface for sending and receiving arbitrary cross-chain messages, so contracts can talk across chains through any bridge (natively or via adapters) without locking into a single vendor's API.","tags":["cross-chain","bridges","messaging","interoperability"],"related":[7930,5164,7683,7841],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7786/","markdown":"## What problem does it solve?\n\nEvery bridge or cross-chain messaging protocol has its own interface, its own workflow and its own trust model. A contract built for one protocol cannot switch to another without being rewritten, and no one can write a generic \"cross-chain app\" that works over any bridge.\n\nERC-7786 defines a small common interface: a **source gateway** to send a message and a **recipient** callback to receive one. Protocols can implement it directly, or someone can build an adapter around an existing protocol. Bridge-specific features are passed as optional **attributes**. It also works with non-EVM chains, because addresses use the chain-agnostic [ERC-7930](/eip-7930/) format.\n\n## How it works\n\n**A message** has a sender, a recipient, an opaque `payload`, an optional native-token `value`, and a list of `attributes`. Sender and recipient are ERC-7930 Interoperable Addresses (binary, CAIP-350 serialised), which encode both the chain and the account.\n\n**Sending.** The source chain's gateway implements `IERC7786GatewaySource`:\n\n- `sendMessage(recipient, payload, attributes)` emits `MessageSent` and may return a non-zero `sendId`. It must revert with `UnsupportedAttribute` for unknown attributes, and must revert if ETH is attached but the gateway does not support value.\n- `supportsAttribute(bytes4)` tells callers which features exist. Each attribute is `bytes4 key ++ value`; keys are recommended to be function selectors, e.g. `minGasLimit(uint256)` → `0x39f87ba1`, so each element can be built with `abi.encodeWithSignature`.\n- Extra steps such as paying for destination gas (\"post-processing\") may be needed; how is out of scope.\n\n**Receiving.** The destination side's protocol calls the recipient's `receiveMessage(receiveId, sender, payload)`, which must return its selector (`0x2432ef26`). The recipient **must check that the caller is a gateway it trusts**.\n\n**Required guarantees:** *safety* (delivered only if sent and finalised, and only once) and *liveness* (eventually delivered if fees are paid). *Timeliness* and decentralised trust are recommended.\n\n## Sample code\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC7786GatewaySource {\n    function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)\n        external payable returns (bytes32 sendId);\n}\n\ninterface IERC7786Recipient {\n    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)\n        external payable returns (bytes4);\n}\n\ncontract PingPong is IERC7786Recipient {\n    address public immutable gateway;\n    constructor(address g) { gateway = g; }\n\n    function ping(bytes calldata remote /* ERC-7930 address */) external payable {\n        bytes[] memory attrs = new bytes[](0);\n        IERC7786GatewaySource(gateway).sendMessage{value: msg.value}(remote, \"ping\", attrs);\n    }\n\n    function receiveMessage(bytes32, bytes calldata, bytes calldata payload)\n        external payable returns (bytes4)\n    {\n        require(msg.sender == gateway, \"untrusted gateway\");\n        // handle payload ...\n        return IERC7786Recipient.receiveMessage.selector;\n    }\n}\n```\n\n## Things to know\n\n- Status is **Final**.\n- The recipient's check on `msg.sender` is your whole security model: you inherit the trust assumptions of every gateway you accept.\n- How a native `value` shows up on the destination chain is unspecified.\n- Use canonical ERC-7930 encodings; the spec warns non-canonical ones can make delivery fail silently.\n- Related work: [ERC-5164](/eip-5164/) (an earlier cross-chain execution interface), [ERC-7683](/eip-7683/) (cross-chain intents) and [ERC-7841](/eip-7841/) (message format and mailbox).\n"},"ja":{"lang":"ja","tldr":"任意のクロスチェーンメッセージを送受信するための単一のゲートウェイインターフェース。コントラクトが、特定ベンダーの API に縛られることなく、（ネイティブまたはアダプター経由で）あらゆるブリッジを通じてチェーン間で通信できる。","tags":["cross-chain","bridges","messaging","interoperability"],"related":[7930,5164,7683,7841],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7786/","markdown":"## 何を解決するのか\n\nブリッジやクロスチェーンメッセージングのプロトコルは、それぞれ独自のインターフェース、ワークフロー、信頼モデルを持っています。あるプロトコル向けに作ったコントラクトは、書き直さない限り別のプロトコルに乗り換えられず、どのブリッジでも動く汎用の「クロスチェーンアプリ」を書くこともできません。\n\nERC-7786 は小さな共通インターフェースを定義します。メッセージを送る**ソースゲートウェイ**と、受け取る**受信者**のコールバックです。プロトコルが直接実装することも、既存のプロトコルをラップするアダプターを誰かが作ることもできます。ブリッジ固有の機能は、任意の**属性（attributes）**として渡します。アドレスにチェーン非依存の [ERC-7930](/eip-7930/) 形式を使うため、非 EVM チェーンでも動作します。\n\n## 仕組み\n\n**メッセージ**は、送信者、受信者、不透明な `payload`、任意のネイティブトークン `value`、`attributes` のリストを持ちます。送信者と受信者は ERC-7930 の Interoperable Address（バイナリ、CAIP-350 でシリアライズ）で、チェーンとアカウントの両方をエンコードします。\n\n**送信。** ソースチェーンのゲートウェイは `IERC7786GatewaySource` を実装します。\n\n- `sendMessage(recipient, payload, attributes)` は `MessageSent` を emit し、0 以外の `sendId` を返すことがあります。未知の属性には `UnsupportedAttribute` で revert しなければならず、ETH が添付されたのにゲートウェイが value に対応していない場合も revert しなければなりません。\n- `supportsAttribute(bytes4)` は、どの機能があるかを呼び出し側に伝えます。各属性は `bytes4 key ++ value` で、キーには関数セレクターを使うことが推奨されます。たとえば `minGasLimit(uint256)` → `0x39f87ba1` で、各要素は `abi.encodeWithSignature` で組み立てられます。\n- 宛先でのガス代の支払い（「ポストプロセッシング」）などの追加ステップが必要になることがありますが、その方法はスコープ外です。\n\n**受信。** 宛先側のプロトコルが受信者の `receiveMessage(receiveId, sender, payload)` を呼び出し、受信者は自身のセレクター（`0x2432ef26`）を返さなければなりません。受信者は**呼び出し元が信頼するゲートウェイであることを確認しなければなりません**。\n\n**必須の保証:** *安全性*（送信され、ファイナライズされた場合にのみ、かつ 1 回だけ配送される）と*活性*（手数料が支払われれば最終的に配送される）。*適時性*と分散型の信頼は推奨です。\n\n## サンプルコード\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC7786GatewaySource {\n    function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)\n        external payable returns (bytes32 sendId);\n}\n\ninterface IERC7786Recipient {\n    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)\n        external payable returns (bytes4);\n}\n\ncontract PingPong is IERC7786Recipient {\n    address public immutable gateway;\n    constructor(address g) { gateway = g; }\n\n    function ping(bytes calldata remote /* ERC-7930 address */) external payable {\n        bytes[] memory attrs = new bytes[](0);\n        IERC7786GatewaySource(gateway).sendMessage{value: msg.value}(remote, \"ping\", attrs);\n    }\n\n    function receiveMessage(bytes32, bytes calldata, bytes calldata payload)\n        external payable returns (bytes4)\n    {\n        require(msg.sender == gateway, \"untrusted gateway\");\n        // handle payload ...\n        return IERC7786Recipient.receiveMessage.selector;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Final** です。\n- 受信者による `msg.sender` のチェックがセキュリティモデルのすべてです。受け入れるすべてのゲートウェイの信頼前提を引き継ぐことになります。\n- ネイティブな `value` が宛先チェーンでどう現れるかは規定されていません。\n- 正規の ERC-7930 エンコーディングを使ってください。仕様は、非正規のものだと配送が黙って失敗することがあると警告しています。\n- 関連する取り組み: [ERC-5164](/eip-5164/)（先行するクロスチェーン実行インターフェース）、[ERC-7683](/eip-7683/)（クロスチェーンインテント）、[ERC-7841](/eip-7841/)（メッセージフォーマットとメールボックス）。\n"},"ko":{"lang":"ko","tldr":"임의의 크로스체인 메시지를 보내고 받기 위한 단일 게이트웨이 인터페이스. 컨트랙트가 특정 벤더의 API에 묶이지 않고 (네이티브 또는 어댑터를 통해) 어떤 브리지로든 체인 간에 통신할 수 있게 한다.","tags":["cross-chain","bridges","messaging","interoperability"],"related":[7930,5164,7683,7841],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7786/","markdown":"## 어떤 문제를 해결하나요?\n\n모든 브리지나 크로스체인 메시징 프로토콜은 저마다 고유한 인터페이스, 워크플로, 신뢰 모델을 가지고 있습니다. 한 프로토콜용으로 만든 컨트랙트는 다시 작성하지 않고는 다른 프로토콜로 바꿀 수 없고, 어떤 브리지에서든 동작하는 범용 \"크로스체인 앱\"을 쓸 수도 없습니다.\n\nERC-7786은 작은 공통 인터페이스를 정의합니다. 메시지를 보내는 **소스 게이트웨이**와 메시지를 받는 **수신자** 콜백입니다. 프로토콜이 직접 구현할 수도 있고, 누군가 기존 프로토콜을 감싸는 어댑터를 만들 수도 있습니다. 브리지별 기능은 선택적인 **속성(attributes)**으로 전달합니다. 주소에 체인에 독립적인 [ERC-7930](/eip-7930/) 형식을 쓰기 때문에 비 EVM 체인에서도 동작합니다.\n\n## 어떻게 동작하나요?\n\n**메시지**는 발신자, 수신자, 불투명한 `payload`, 선택적 네이티브 토큰 `value`, `attributes` 목록으로 이루어집니다. 발신자와 수신자는 ERC-7930 Interoperable Address(바이너리, CAIP-350 직렬화)이며 체인과 계정을 모두 인코딩합니다.\n\n**보내기.** 소스 체인의 게이트웨이는 `IERC7786GatewaySource`를 구현합니다.\n\n- `sendMessage(recipient, payload, attributes)`는 `MessageSent`를 emit하며 0이 아닌 `sendId`를 반환할 수 있습니다. 알 수 없는 속성에는 `UnsupportedAttribute`로 revert해야 하고, ETH가 첨부되었는데 게이트웨이가 value를 지원하지 않으면 revert해야 합니다.\n- `supportsAttribute(bytes4)`는 어떤 기능이 있는지 호출자에게 알려줍니다. 각 속성은 `bytes4 key ++ value`이며, 키는 함수 셀렉터로 하는 것이 권장됩니다. 예를 들어 `minGasLimit(uint256)` → `0x39f87ba1`이며, 각 요소는 `abi.encodeWithSignature`로 만들 수 있습니다.\n- 목적지 가스비 지불(\"후처리\") 같은 추가 단계가 필요할 수 있지만, 그 방식은 범위 밖입니다.\n\n**받기.** 목적지 쪽 프로토콜이 수신자의 `receiveMessage(receiveId, sender, payload)`를 호출하며, 수신자는 자신의 셀렉터(`0x2432ef26`)를 반환해야 합니다. 수신자는 **호출자가 신뢰하는 게이트웨이인지 반드시 확인해야 합니다**.\n\n**필수 보장:** *안전성*(전송되고 확정된 경우에만, 그리고 한 번만 전달됨)과 *활성*(수수료가 지불되면 결국 전달됨). *적시성*과 분산된 신뢰는 권장 사항입니다.\n\n## 샘플 코드\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC7786GatewaySource {\n    function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)\n        external payable returns (bytes32 sendId);\n}\n\ninterface IERC7786Recipient {\n    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)\n        external payable returns (bytes4);\n}\n\ncontract PingPong is IERC7786Recipient {\n    address public immutable gateway;\n    constructor(address g) { gateway = g; }\n\n    function ping(bytes calldata remote /* ERC-7930 address */) external payable {\n        bytes[] memory attrs = new bytes[](0);\n        IERC7786GatewaySource(gateway).sendMessage{value: msg.value}(remote, \"ping\", attrs);\n    }\n\n    function receiveMessage(bytes32, bytes calldata, bytes calldata payload)\n        external payable returns (bytes4)\n    {\n        require(msg.sender == gateway, \"untrusted gateway\");\n        // handle payload ...\n        return IERC7786Recipient.receiveMessage.selector;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Final**입니다.\n- 수신자의 `msg.sender` 확인이 보안 모델 전부입니다. 받아들이는 모든 게이트웨이의 신뢰 가정을 그대로 물려받게 됩니다.\n- 네이티브 `value`가 목적지 체인에서 어떻게 나타나는지는 정해져 있지 않습니다.\n- 정규 ERC-7930 인코딩을 사용하세요. 사양은 정규가 아닌 인코딩은 전달이 조용히 실패할 수 있다고 경고합니다.\n- 관련 작업: [ERC-5164](/eip-5164/)(이전의 크로스체인 실행 인터페이스), [ERC-7683](/eip-7683/)(크로스체인 인텐트), [ERC-7841](/eip-7841/)(메시지 포맷과 메일박스).\n"},"zh":{"lang":"zh","tldr":"用于发送和接收任意跨链消息的统一网关接口，使合约可以通过任何桥（原生或通过适配器）跨链通信，而不会被锁定在单一厂商的 API 上。","tags":["cross-chain","bridges","messaging","interoperability"],"related":[7930,5164,7683,7841],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7786/","markdown":"## 它解决什么问题？\n\n每个桥或跨链消息协议都有自己的接口、自己的工作流和自己的信任模型。为某个协议构建的合约无法在不重写的情况下切换到另一个协议，也没有人能写出适用于任何桥的通用\"跨链应用\"。\n\nERC-7786 定义了一个小型的通用接口：用于发送消息的**源网关**，以及用于接收消息的**接收方**回调。协议可以直接实现它，也可以有人围绕现有协议构建适配器。桥特有的功能以可选的**属性（attributes）**传递。它也适用于非 EVM 链，因为地址使用与链无关的 [ERC-7930](/eip-7930/) 格式。\n\n## 它如何运作\n\n**消息**包含发送方、接收方、不透明的 `payload`、可选的原生代币 `value`，以及一个 `attributes` 列表。发送方和接收方是 ERC-7930 的 Interoperable Address（二进制，按 CAIP-350 序列化），同时编码了链和账户。\n\n**发送。**源链的网关实现 `IERC7786GatewaySource`：\n\n- `sendMessage(recipient, payload, attributes)` 触发 `MessageSent`，并可能返回一个非零的 `sendId`。对于未知属性它必须以 `UnsupportedAttribute` revert；如果附带了 ETH 但网关不支持 value，也必须 revert。\n- `supportsAttribute(bytes4)` 告诉调用者有哪些功能。每个属性是 `bytes4 key ++ value`；建议以函数选择器作为 key，例如 `minGasLimit(uint256)` → `0x39f87ba1`，这样每个元素都可以用 `abi.encodeWithSignature` 构造。\n- 可能还需要额外步骤，例如支付目标链的 gas（\"后处理\"）；具体方式不在范围之内。\n\n**接收。**目标侧的协议调用接收方的 `receiveMessage(receiveId, sender, payload)`，接收方必须返回它的选择器（`0x2432ef26`）。接收方**必须检查调用者是它所信任的网关**。\n\n**必需的保证：***安全性*（只有已发送并已最终确认的消息才会被投递，且只投递一次）和*活性*（只要支付了费用，最终会被投递）。*及时性*和去中心化信任是建议项。\n\n## 示例代码\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC7786GatewaySource {\n    function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)\n        external payable returns (bytes32 sendId);\n}\n\ninterface IERC7786Recipient {\n    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)\n        external payable returns (bytes4);\n}\n\ncontract PingPong is IERC7786Recipient {\n    address public immutable gateway;\n    constructor(address g) { gateway = g; }\n\n    function ping(bytes calldata remote /* ERC-7930 address */) external payable {\n        bytes[] memory attrs = new bytes[](0);\n        IERC7786GatewaySource(gateway).sendMessage{value: msg.value}(remote, \"ping\", attrs);\n    }\n\n    function receiveMessage(bytes32, bytes calldata, bytes calldata payload)\n        external payable returns (bytes4)\n    {\n        require(msg.sender == gateway, \"untrusted gateway\");\n        // handle payload ...\n        return IERC7786Recipient.receiveMessage.selector;\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Final**。\n- 接收方对 `msg.sender` 的检查就是你整个的安全模型：你继承了你所接受的每个网关的信任假设。\n- 原生 `value` 如何出现在目标链上并未规定。\n- 请使用规范的 ERC-7930 编码；规范警告说，非规范的编码可能导致投递悄无声息地失败。\n- 相关工作：[ERC-5164](/eip-5164/)（较早的跨链执行接口）、[ERC-7683](/eip-7683/)（跨链意图）和 [ERC-7841](/eip-7841/)（消息格式和 mailbox）。\n"}},"requiredBy":[7965,7985]}
