{"eip":6170,"title":"Cross-Chain Messaging Interface","description":"A common smart contract interface for interacting with messaging protocols.","authors":["Sujith Somraaj (@sujithsomraaj)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2022-12-19","discussionsTo":"https://ethereum-magicians.org/t/cross-chain-messaging-standard/12197","repo":"ERCs","label":"ERC-6170","officialUrl":"https://eips.ethereum.org/EIPS/eip-6170","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6170.md","url":"https://eips.huatuo.xyz/eip-6170/","tldr":{"en":"A draft common interface for cross-chain message bridges, with one sendMessage and one receiveMessage function using bytes everywhere so apps can switch bridges and reach non-EVM chains.","ja":"クロスチェーンのメッセージブリッジ向けドラフトの共通インターフェース。sendMessage と receiveMessage の 2 つの関数があり、あらゆる場所で bytes を使うことで、アプリがブリッジを切り替えたり EVM 以外のチェーンに到達したりできる。","ko":"크로스체인 메시지 브리지를 위한 드래프트 공통 인터페이스. sendMessage 함수 하나와 receiveMessage 함수 하나로 구성되며 모든 곳에 bytes를 사용해, 앱이 브리지를 바꾸거나 EVM이 아닌 체인에 도달할 수 있게 한다.","zh":"一个面向跨链消息桥的草案通用接口，只有一个 sendMessage 和一个 receiveMessage 函数，并全部使用 bytes，使应用可以切换桥并接入非 EVM 链。"},"tags":["cross-chain","bridge","messaging","interoperability"],"explainers":{"en":{"lang":"en","tldr":"A draft common interface for cross-chain message bridges, with one sendMessage and one receiveMessage function using bytes everywhere so apps can switch bridges and reach non-EVM chains.","tags":["cross-chain","bridge","messaging","interoperability"],"related":[5164],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-6170/","markdown":"## What problem does it solve?\n\nCross-chain apps send messages through arbitrary message bridges (AMBs), and each bridge has its own API, its own replay protection and its own security assumptions. An app written against one bridge is effectively locked in: if that bridge goes down or is compromised, moving to another means rewriting integration code and possibly migrating state.\n\nERC-6170 proposes a minimal shared interface for bridges, so an application can talk to any compliant bridge the same way and swap or combine bridges by changing an address.\n\n## How it works\n\nA compliant bridge exposes two functions and two events:\n\n| Member | Role |\n| --- | --- |\n| `sendMessage(chainId, receiver, message, data)` | Send `message` to `receiver` on chain `chainId`. Payable to cover relaying fees. |\n| `receiveMessage(chainId, sender, message, data)` | Deliver an incoming message from `sender` on chain `chainId`. |\n| `MessageSent(to, toChainId, message, extraData)` | Must fire on every send, even zero-byte messages |\n| `MessageReceived(from, fromChainId, message)` | Must fire on every successful receive |\n\nDesign choices:\n\n- **Everything is `bytes`.** Chain IDs and addresses are `bytes` rather than `uint256` / `address`, so the same interface can address non-EVM chains whose addresses are not 20 bytes. The draft suggests encoding a chain ID as the ABI-encoded name of its native token (for example `abi.encode(\"ETH\")`).\n- **`data` is bridge-specific.** On send it carries whatever the bridge's relayers need; on receive it can carry security data such as a nonce or proof.\n- Both functions return a `bool` status.\n\nAuthentication is out of scope: the receiving side must validate the sender and message itself before acting.\n\n## Sample code\n\nThe interface and an app that only accepts messages from a known peer:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IEIP6170 {\n    event MessageSent(bytes to, bytes toChainId, bytes message, bytes extraData);\n    event MessageReceived(bytes from, bytes fromChainId, bytes message);\n\n    function sendMessage(bytes memory chainId_, bytes memory receiver_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n    function receiveMessage(bytes memory chainId_, bytes memory sender_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n}\n\ncontract Pinger {\n    IEIP6170 public bridge;\n    bytes public peerChain;\n    bytes public peer;\n\n    constructor(IEIP6170 b, bytes memory chain, bytes memory p) { bridge = b; peerChain = chain; peer = p; }\n\n    function ping(bytes calldata relayerData) external payable {\n        bridge.sendMessage{value: msg.value}(peerChain, peer, abi.encode(\"ping\"), relayerData);\n    }\n\n    // called by the bridge on delivery\n    function onMessage(bytes calldata fromChain, bytes calldata from, bytes calldata message) external {\n        require(msg.sender == address(bridge), \"only bridge\");\n        require(keccak256(fromChain) == keccak256(peerChain) \u0026\u0026 keccak256(from) == keccak256(peer), \"unknown peer\");\n        // handle message...\n    }\n}\n```\n\nHow the bridge calls into the destination app (`onMessage` above) is not specified by the draft; each bridge defines its own delivery hook.\n\n## Things to know\n\n- Status is **Draft**: the interface is not finalized and may change. Check whether a given bridge actually implements it before relying on it.\n- Without sender authentication, anyone could inject messages into the receiving contract. Always check origin chain and sender.\n- Using several bridges through one interface reduces single-point-of-failure risk only if the app also checks each bridge's security model.\n- A related effort at a standard cross-chain execution interface is [ERC-5164](/eip-5164/).\n"},"ja":{"lang":"ja","tldr":"クロスチェーンのメッセージブリッジ向けドラフトの共通インターフェース。sendMessage と receiveMessage の 2 つの関数があり、あらゆる場所で bytes を使うことで、アプリがブリッジを切り替えたり EVM 以外のチェーンに到達したりできる。","tags":["cross-chain","bridge","messaging","interoperability"],"related":[5164],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-6170/","markdown":"## 何を解決するのか\n\nクロスチェーンアプリは任意のメッセージブリッジ（AMB）を通じてメッセージを送りますが、ブリッジごとに独自の API、独自のリプレイ保護、独自のセキュリティ前提があります。あるブリッジ向けに書かれたアプリは、事実上ロックインされます。そのブリッジが停止したり侵害されたりした場合、別のものに移るには、統合コードを書き直し、場合によってはステートを移行する必要があります。\n\nERC-6170 は、ブリッジ向けの最小限の共通インターフェースを提案します。これにより、アプリケーションは準拠するどのブリッジとも同じ方法でやり取りでき、アドレスを変えるだけでブリッジを入れ替えたり組み合わせたりできます。\n\n## 仕組み\n\n準拠するブリッジは、2 つの関数と 2 つのイベントを公開します。\n\n| メンバー | 役割 |\n| --- | --- |\n| `sendMessage(chainId, receiver, message, data)` | チェーン `chainId` 上の `receiver` に `message` を送る。リレー手数料をまかなうため payable。 |\n| `receiveMessage(chainId, sender, message, data)` | チェーン `chainId` 上の `sender` からの受信メッセージを配送する。 |\n| `MessageSent(to, toChainId, message, extraData)` | 0 バイトのメッセージを含め、送信のたびに必ず発火しなければならない |\n| `MessageReceived(from, fromChainId, message)` | 受信に成功するたびに必ず発火しなければならない |\n\n設計上の選択:\n\n- **すべてが `bytes`。** チェーン ID とアドレスは `uint256` / `address` ではなく `bytes` なので、アドレスが 20 バイトではない EVM 以外のチェーンも、同じインターフェースで指定できます。ドラフトは、チェーン ID をそのネイティブトークンの名前を ABI エンコードしたもの（たとえば `abi.encode(\"ETH\")`）としてエンコードすることを提案しています。\n- **`data` はブリッジ固有。** 送信時には、ブリッジのリレイヤーが必要とするものを運び、受信時には nonce や証明などのセキュリティデータを運べます。\n- どちらの関数も `bool` のステータスを返します。\n\n認証は対象外です。受信側は、動作する前に、送信者とメッセージを自分で検証しなければなりません。\n\n## サンプルコード\n\nインターフェースと、既知のピアからのメッセージのみを受け付けるアプリ:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IEIP6170 {\n    event MessageSent(bytes to, bytes toChainId, bytes message, bytes extraData);\n    event MessageReceived(bytes from, bytes fromChainId, bytes message);\n\n    function sendMessage(bytes memory chainId_, bytes memory receiver_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n    function receiveMessage(bytes memory chainId_, bytes memory sender_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n}\n\ncontract Pinger {\n    IEIP6170 public bridge;\n    bytes public peerChain;\n    bytes public peer;\n\n    constructor(IEIP6170 b, bytes memory chain, bytes memory p) { bridge = b; peerChain = chain; peer = p; }\n\n    function ping(bytes calldata relayerData) external payable {\n        bridge.sendMessage{value: msg.value}(peerChain, peer, abi.encode(\"ping\"), relayerData);\n    }\n\n    // called by the bridge on delivery\n    function onMessage(bytes calldata fromChain, bytes calldata from, bytes calldata message) external {\n        require(msg.sender == address(bridge), \"only bridge\");\n        require(keccak256(fromChain) == keccak256(peerChain) \u0026\u0026 keccak256(from) == keccak256(peer), \"unknown peer\");\n        // handle message...\n    }\n}\n```\n\nブリッジが宛先のアプリをどのように呼び出すか（上の `onMessage`）は、ドラフトでは規定されていません。各ブリッジが独自の配送フックを定義します。\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。インターフェースは確定しておらず、変更される可能性があります。頼る前に、使用するブリッジが実際にこれを実装しているか確認してください。\n- 送信者の認証がなければ、誰でも受信側のコントラクトにメッセージを注入できます。必ず送信元のチェーンと送信者を確認してください。\n- 1 つのインターフェースで複数のブリッジを使うと、単一障害点のリスクが下がりますが、それはアプリが各ブリッジのセキュリティモデルも確認する場合に限ります。\n- 標準的なクロスチェーン実行インターフェースを目指す関連の取り組みとして [ERC-5164](/eip-5164/) があります。\n"},"ko":{"lang":"ko","tldr":"크로스체인 메시지 브리지를 위한 드래프트 공통 인터페이스. sendMessage 함수 하나와 receiveMessage 함수 하나로 구성되며 모든 곳에 bytes를 사용해, 앱이 브리지를 바꾸거나 EVM이 아닌 체인에 도달할 수 있게 한다.","tags":["cross-chain","bridge","messaging","interoperability"],"related":[5164],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-6170/","markdown":"## 어떤 문제를 해결하나요?\n\n크로스체인 앱은 임의의 메시지 브리지(AMB)를 통해 메시지를 보내는데, 브리지마다 자기만의 API, 리플레이 방지, 보안 가정이 있습니다. 한 브리지에 맞춰 작성된 앱은 사실상 종속됩니다. 그 브리지가 중단되거나 침해되면 다른 브리지로 옮기려면 연동 코드를 다시 작성해야 하고 상태를 이전해야 할 수도 있습니다.\n\nERC-6170은 브리지를 위한 최소한의 공유 인터페이스를 제안하여, 애플리케이션이 규격을 따르는 어떤 브리지와도 같은 방식으로 통신하고 주소만 바꿔 브리지를 교체하거나 조합할 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n규격을 따르는 브리지는 함수 두 개와 이벤트 두 개를 노출합니다.\n\n| 멤버 | 역할 |\n| --- | --- |\n| `sendMessage(chainId, receiver, message, data)` | 체인 `chainId`의 `receiver`에게 `message`를 보냅니다. 릴레이 수수료를 충당하기 위해 payable. |\n| `receiveMessage(chainId, sender, message, data)` | 체인 `chainId`의 `sender`가 보낸 수신 메시지를 전달합니다. |\n| `MessageSent(to, toChainId, message, extraData)` | 0바이트 메시지를 포함해 모든 전송마다 반드시 발생해야 함 |\n| `MessageReceived(from, fromChainId, message)` | 수신에 성공할 때마다 반드시 발생해야 함 |\n\n설계상의 선택:\n\n- **모든 것이 `bytes`입니다.** 체인 ID와 주소는 `uint256` / `address`가 아니라 `bytes`이므로, 주소가 20바이트가 아닌 EVM 외 체인도 같은 인터페이스로 지정할 수 있습니다. 드래프트는 체인 ID를 해당 체인 네이티브 토큰 이름을 ABI 인코딩한 값(예: `abi.encode(\"ETH\")`)으로 인코딩할 것을 제안합니다.\n- **`data`는 브리지마다 다릅니다.** 전송 시에는 브리지의 릴레이어가 필요로 하는 것을 담고, 수신 시에는 nonce나 증명 같은 보안 데이터를 담을 수 있습니다.\n- 두 함수 모두 `bool` 상태를 반환합니다.\n\n인증은 범위 밖입니다. 수신 측은 동작하기 전에 발신자와 메시지를 스스로 검증해야 합니다.\n\n## 샘플 코드\n\n인터페이스와, 알려진 피어의 메시지만 받는 앱:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IEIP6170 {\n    event MessageSent(bytes to, bytes toChainId, bytes message, bytes extraData);\n    event MessageReceived(bytes from, bytes fromChainId, bytes message);\n\n    function sendMessage(bytes memory chainId_, bytes memory receiver_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n    function receiveMessage(bytes memory chainId_, bytes memory sender_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n}\n\ncontract Pinger {\n    IEIP6170 public bridge;\n    bytes public peerChain;\n    bytes public peer;\n\n    constructor(IEIP6170 b, bytes memory chain, bytes memory p) { bridge = b; peerChain = chain; peer = p; }\n\n    function ping(bytes calldata relayerData) external payable {\n        bridge.sendMessage{value: msg.value}(peerChain, peer, abi.encode(\"ping\"), relayerData);\n    }\n\n    // called by the bridge on delivery\n    function onMessage(bytes calldata fromChain, bytes calldata from, bytes calldata message) external {\n        require(msg.sender == address(bridge), \"only bridge\");\n        require(keccak256(fromChain) == keccak256(peerChain) \u0026\u0026 keccak256(from) == keccak256(peer), \"unknown peer\");\n        // handle message...\n    }\n}\n```\n\n브리지가 대상 앱을 어떻게 호출하는지(위의 `onMessage`)는 드래프트가 규정하지 않으며, 각 브리지가 자기만의 전달 훅을 정의합니다.\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 인터페이스는 확정되지 않았으며 바뀔 수 있습니다. 의존하기 전에 사용하는 브리지가 실제로 이를 구현하는지 확인하세요.\n- 발신자 인증이 없으면 누구나 수신 컨트랙트에 메시지를 주입할 수 있습니다. 항상 출발 체인과 발신자를 확인하세요.\n- 하나의 인터페이스로 여러 브리지를 쓰면 단일 장애점 위험이 줄어들지만, 이는 앱이 각 브리지의 보안 모델도 확인할 때에만 해당합니다.\n- 표준 크로스체인 실행 인터페이스를 위한 관련 노력으로 [ERC-5164](/eip-5164/)가 있습니다.\n"},"zh":{"lang":"zh","tldr":"一个面向跨链消息桥的草案通用接口，只有一个 sendMessage 和一个 receiveMessage 函数，并全部使用 bytes，使应用可以切换桥并接入非 EVM 链。","tags":["cross-chain","bridge","messaging","interoperability"],"related":[5164],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-6170/","markdown":"## 它解决什么问题？\n\n跨链应用通过任意消息桥（AMB）发送消息，而每个桥都有自己的 API、自己的重放保护和自己的安全假设。针对某一个桥编写的应用实际上被锁定了：如果该桥宕机或被攻破，迁移到另一个桥就意味着重写集成代码，还可能需要迁移状态。\n\nERC-6170 为桥提出了一个最小的共享接口，使应用可以用同样的方式与任何合规的桥交互，并通过更换地址来切换或组合多个桥。\n\n## 它如何运作\n\n合规的桥公开两个函数和两个事件：\n\n| 成员 | 作用 |\n| --- | --- |\n| `sendMessage(chainId, receiver, message, data)` | 向链 `chainId` 上的 `receiver` 发送 `message`。为支付中继费用而为 payable。 |\n| `receiveMessage(chainId, sender, message, data)` | 投递来自链 `chainId` 上 `sender` 的传入消息。 |\n| `MessageSent(to, toChainId, message, extraData)` | 每次发送都必须触发，即使是零字节的消息 |\n| `MessageReceived(from, fromChainId, message)` | 每次成功接收都必须触发 |\n\n设计选择：\n\n- **一切都是 `bytes`。** 链 ID 和地址使用 `bytes` 而不是 `uint256` / `address`，因此同一个接口可以寻址地址不是 20 字节的非 EVM 链。草案建议把链 ID 编码为其原生代币名称的 ABI 编码（例如 `abi.encode(\"ETH\")`）。\n- **`data` 因桥而异。** 发送时它携带桥的中继者所需的任何内容；接收时它可以携带 nonce 或证明等安全数据。\n- 两个函数都返回一个 `bool` 状态。\n\n认证不在范围之内：接收方在采取行动之前，必须自行验证发送者和消息。\n\n## 示例代码\n\n接口，以及一个只接受来自已知对端的消息的应用：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IEIP6170 {\n    event MessageSent(bytes to, bytes toChainId, bytes message, bytes extraData);\n    event MessageReceived(bytes from, bytes fromChainId, bytes message);\n\n    function sendMessage(bytes memory chainId_, bytes memory receiver_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n    function receiveMessage(bytes memory chainId_, bytes memory sender_, bytes memory message_, bytes memory data_)\n        external payable returns (bool);\n}\n\ncontract Pinger {\n    IEIP6170 public bridge;\n    bytes public peerChain;\n    bytes public peer;\n\n    constructor(IEIP6170 b, bytes memory chain, bytes memory p) { bridge = b; peerChain = chain; peer = p; }\n\n    function ping(bytes calldata relayerData) external payable {\n        bridge.sendMessage{value: msg.value}(peerChain, peer, abi.encode(\"ping\"), relayerData);\n    }\n\n    // called by the bridge on delivery\n    function onMessage(bytes calldata fromChain, bytes calldata from, bytes calldata message) external {\n        require(msg.sender == address(bridge), \"only bridge\");\n        require(keccak256(fromChain) == keccak256(peerChain) \u0026\u0026 keccak256(from) == keccak256(peer), \"unknown peer\");\n        // handle message...\n    }\n}\n```\n\n桥如何调用目标应用（上面的 `onMessage`），草案没有规定；每个桥定义自己的投递钩子。\n\n## 需要注意\n\n- 状态为 **Draft**：接口尚未定稿，可能会变化。在依赖它之前，请确认具体的桥是否真的实现了它。\n- 没有发送者认证，任何人都可以向接收合约注入消息。务必检查来源链和发送者。\n- 通过一个接口使用多个桥，只有在应用同时检查每个桥的安全模型时，才能降低单点故障的风险。\n- 与之相关的、致力于标准跨链执行接口的工作是 [ERC-5164](/eip-5164/)。\n"}}}
