{"eip":7615,"title":"Atomic Push-based Data Feed Among Contracts","description":"An Atomic Mechanism to Allow Publisher Contract Push Data to Subcriber Contracts","authors":["Elaine Zhang (@lanyinzly) \u003clz8aj@virginia.edu\u003e","Jerry \u003cjerrymindflow@gmail.com\u003e","Amandafanny \u003camandafanny200@gmail.com\u003e","Shouhao Wong (@wangshouh) \u003cwongshouhao@outlook.com\u003e","Doris Che (@Cheyukj) \u003cdorischeyy@gmail.com\u003e","Henry Yuan (@onehumanbeing) \u003chy2878@nyu.edu\u003e"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2024-02-03","discussionsTo":"https://ethereum-magicians.org/t/erc-7615-smart-contract-data-push-mechanism/18466","repo":"ERCs","label":"ERC-7615","officialUrl":"https://eips.ethereum.org/EIPS/eip-7615","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7615.md","url":"https://eips.huatuo.xyz/eip-7615/","tldr":{"en":"A draft publish/subscribe pattern for contracts: when a publisher function runs, it calls exec() on every subscriber registered for that function selector in the same transaction, replacing off-chain keepers that watch events.","ja":"コントラクト向けのドラフトのパブリッシュ/サブスクライブパターン。パブリッシャーの関数が実行されると、同じトランザクション内で、その関数セレクターに登録されたすべてのサブスクライバーの exec() を呼び出し、イベントを監視するオフチェーンの keeper を置き換える。","ko":"컨트랙트를 위한 초안 발행/구독(publish/subscribe) 패턴. 발행자 함수가 실행되면 같은 트랜잭션 안에서 해당 함수 셀렉터에 등록된 모든 구독자의 exec()를 호출해, 이벤트를 지켜보는 오프체인 keeper를 대체한다.","zh":"一种面向合约的草案发布/订阅模式：发布者函数运行时，会在同一笔交易中对为该函数选择器注册的每个订阅者调用 exec()，以取代监视事件的链下 keeper。"},"tags":["oracle","pubsub","automation","hooks","defi"],"explainers":{"en":{"lang":"en","tldr":"A draft publish/subscribe pattern for contracts: when a publisher function runs, it calls exec() on every subscriber registered for that function selector in the same transaction, replacing off-chain keepers that watch events.","tags":["oracle","pubsub","automation","hooks","defi"],"related":[1153,6551],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7615/","markdown":"## What problem does it solve?\n\nWhen one contract needs to react to something that happens in another (a price update, an NFT transfer, a finished vote), the usual answer is an off-chain keeper: a bot watches events and sends a follow-up transaction. That adds trust in the bot, latency between the two steps, and a window where state is inconsistent.\n\nERC-7615 proposes that the source contract (the **publisher**) push the update to interested contracts (the **subscribers**) directly, inside the same call. Examples from the spec: an oracle pushing prices to a lending protocol that liquidates on the spot; an NFT contract telling a staking contract a token moved so it can unstake, letting users stake without transferring the NFT; a DAO contract executing a vote's result as soon as it closes.\n\n## How it works\n\n1. A publisher function is called and runs an internal `_push(selector, data)` hook.\n2. The publisher looks up the subscribers registered for that function's `selector`.\n3. It calls `exec(selector, data)` on each subscriber.\n4. The subscriber acts on it, optionally calling the publisher's `inbox(selector)` to fetch fuller data (the reference implementation keeps it in transient storage, [EIP-1153](/eip-1153/)).\n\nTwo kinds of subscription:\n\n- **Unconditional** (`IPushForce`): `forceApprove(selector, target)` makes every call to that selector push to `target`. Suited to price feeds.\n- **Conditional** (`IPushFree`): `approve(selector, target, data)` only pushes when the call matches `data` (for example, a specific `tokenId`). Saves gas for everyone else.\n\nSubscribers implement `IExec` with `exec` and `isLocked`. Before removing a subscription (`cancel` / `forceCancel`), the publisher must check `isLocked`, so a subscriber that depends on the feed cannot be cut off unilaterally. The publisher can also permanently give up the power to add or remove unconditional subscribers with `renounceForceApprove` / `renounceForceCancel`.\n\n## Sample code\n\nA subscriber that only trusts one publisher:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\ninterface IExec {\n    function isLocked(bytes4 selector, bytes calldata data) external returns (bool);\n    function exec(bytes4 selector, bytes calldata data) external;\n}\n\ncontract PriceSubscriber is IExec {\n    address public immutable publisher;\n    bytes4 public immutable priceSelector;\n    uint256 public lastPrice;\n    uint256 public openPositions;\n\n    constructor(address pub, bytes4 sel) { publisher = pub; priceSelector = sel; }\n\n    function exec(bytes4 selector, bytes calldata data) external {\n        require(msg.sender == publisher, \"untrusted caller\"); // exec is public\n        require(selector == priceSelector, \"unexpected selector\");\n        lastPrice = abi.decode(data, (uint256));\n        // ... check positions and liquidate if needed\n    }\n\n    // Refuse unsubscription while positions depend on the feed.\n    function isLocked(bytes4, bytes calldata) external view returns (bool) {\n        return openPositions \u003e 0;\n    }\n}\n```\n\n## Things to know\n\n- Status: **Draft**.\n- The caller of the publisher pays gas for every subscriber's `exec`. A long or expensive subscriber list can make the publisher's function costly or push it over the block gas limit, so `approve` and `forceApprove` need access control.\n- `exec` is callable by anyone; subscribers must verify `msg.sender` and validate data.\n- Calling untrusted subscribers opens reentrancy paths back into the publisher; use reentrancy guards and checks-effects-interactions.\n- A subscriber whose `isLocked` always returns `true` can never be removed; publishers should check this before subscribing it.\n"},"ja":{"lang":"ja","tldr":"コントラクト向けのドラフトのパブリッシュ/サブスクライブパターン。パブリッシャーの関数が実行されると、同じトランザクション内で、その関数セレクターに登録されたすべてのサブスクライバーの exec() を呼び出し、イベントを監視するオフチェーンの keeper を置き換える。","tags":["oracle","pubsub","automation","hooks","defi"],"related":[1153,6551],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7615/","markdown":"## 何を解決するのか\n\nあるコントラクトが別のコントラクトで起きたこと（価格の更新、NFT の転送、投票の終了）に反応する必要があるとき、通常の答えはオフチェーンの keeper です。ボットがイベントを監視し、後続のトランザクションを送ります。これにより、ボットへの信頼、2 つのステップの間のレイテンシ、状態が不整合になる時間枠が加わります。\n\nERC-7615 は、ソースとなるコントラクト（**パブリッシャー**）が、関心を持つコントラクト（**サブスクライバー**）に、同じ呼び出しの中で直接更新をプッシュすることを提案します。仕様の例: オラクルが価格をレンディングプロトコルにプッシュし、その場で清算が行われる。NFT コントラクトがステーキングコントラクトにトークンが移動したことを伝え、アンステークできるようにして、NFT を転送せずにステークできるようにする。DAO コントラクトが投票の終了と同時にその結果を実行する。\n\n## 仕組み\n\n1. パブリッシャーの関数が呼び出され、内部の `_push(selector, data)` フックを実行します。\n2. パブリッシャーは、その関数の `selector` に登録されたサブスクライバーを調べます。\n3. 各サブスクライバーの `exec(selector, data)` を呼び出します。\n4. サブスクライバーはそれに基づいて動作し、必要に応じてパブリッシャーの `inbox(selector)` を呼んでより詳しいデータを取得します（リファレンス実装はこれを transient storage（[EIP-1153](/eip-1153/)）に保持します）。\n\nサブスクリプションには 2 種類あります。\n\n- **無条件**（`IPushForce`）: `forceApprove(selector, target)` により、そのセレクターへのすべての呼び出しが `target` にプッシュされます。価格フィードに向いています。\n- **条件付き**（`IPushFree`）: `approve(selector, target, data)` は、呼び出しが `data`（たとえば特定の `tokenId`）に一致する場合にのみプッシュします。ほかの全員の gas を節約できます。\n\nサブスクライバーは `exec` と `isLocked` を持つ `IExec` を実装します。サブスクリプションを削除する（`cancel` / `forceCancel`）前に、パブリッシャーは `isLocked` を確認しなければならず、フィードに依存しているサブスクライバーが一方的に切り離されることはありません。パブリッシャーは、`renounceForceApprove` / `renounceForceCancel` によって、無条件サブスクライバーを追加・削除する権限を恒久的に放棄することもできます。\n\n## サンプルコード\n\n1 つのパブリッシャーだけを信頼するサブスクライバー:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\ninterface IExec {\n    function isLocked(bytes4 selector, bytes calldata data) external returns (bool);\n    function exec(bytes4 selector, bytes calldata data) external;\n}\n\ncontract PriceSubscriber is IExec {\n    address public immutable publisher;\n    bytes4 public immutable priceSelector;\n    uint256 public lastPrice;\n    uint256 public openPositions;\n\n    constructor(address pub, bytes4 sel) { publisher = pub; priceSelector = sel; }\n\n    function exec(bytes4 selector, bytes calldata data) external {\n        require(msg.sender == publisher, \"untrusted caller\"); // exec is public\n        require(selector == priceSelector, \"unexpected selector\");\n        lastPrice = abi.decode(data, (uint256));\n        // ... check positions and liquidate if needed\n    }\n\n    // Refuse unsubscription while positions depend on the feed.\n    function isLocked(bytes4, bytes calldata) external view returns (bool) {\n        return openPositions \u003e 0;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータス: **Draft**。\n- パブリッシャーの呼び出し元は、すべてのサブスクライバーの `exec` の gas を支払います。サブスクライバーのリストが長い、または重いと、パブリッシャーの関数のコストが高くなったり、ブロックの gas limit を超えたりする可能性があるため、`approve` と `forceApprove` にはアクセス制御が必要です。\n- `exec` は誰でも呼び出せます。サブスクライバーは `msg.sender` を検証し、データを検証しなければなりません。\n- 信頼できないサブスクライバーを呼び出すと、パブリッシャーへのリエントランシーの経路が開きます。リエントランシーガードと checks-effects-interactions を使ってください。\n- `isLocked` が常に `true` を返すサブスクライバーは、決して削除できません。パブリッシャーは、サブスクライブさせる前にこれを確認すべきです。\n"},"ko":{"lang":"ko","tldr":"컨트랙트를 위한 초안 발행/구독(publish/subscribe) 패턴. 발행자 함수가 실행되면 같은 트랜잭션 안에서 해당 함수 셀렉터에 등록된 모든 구독자의 exec()를 호출해, 이벤트를 지켜보는 오프체인 keeper를 대체한다.","tags":["oracle","pubsub","automation","hooks","defi"],"related":[1153,6551],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7615/","markdown":"## 어떤 문제를 해결하나요?\n\n한 컨트랙트가 다른 컨트랙트에서 일어난 일(가격 업데이트, NFT 전송, 투표 종료)에 반응해야 할 때 보통의 해법은 오프체인 keeper입니다. 봇이 이벤트를 지켜보다가 후속 트랜잭션을 보냅니다. 이렇게 하면 봇에 대한 신뢰, 두 단계 사이의 지연, 상태가 일관되지 않은 구간이 생깁니다.\n\nERC-7615는 원천 컨트랙트(**발행자**)가 관심 있는 컨트랙트(**구독자**)에게 같은 호출 안에서 직접 업데이트를 푸시하자고 제안합니다. 스펙의 예: 오라클이 대출 프로토콜에 가격을 푸시해 그 자리에서 청산이 이루어짐, NFT 컨트랙트가 스테이킹 컨트랙트에 토큰이 이동했음을 알려 언스테이크하게 함으로써 사용자가 NFT를 전송하지 않고도 스테이킹할 수 있게 함, DAO 컨트랙트가 투표가 끝나자마자 결과를 실행함.\n\n## 어떻게 동작하나요?\n\n1. 발행자 함수가 호출되어 내부 `_push(selector, data)` 훅을 실행합니다.\n2. 발행자는 그 함수의 `selector`에 등록된 구독자를 조회합니다.\n3. 각 구독자에게 `exec(selector, data)`를 호출합니다.\n4. 구독자는 이에 따라 동작하며, 필요하면 발행자의 `inbox(selector)`를 호출해 더 자세한 데이터를 가져옵니다(레퍼런스 구현은 이를 transient storage([EIP-1153](/eip-1153/))에 보관합니다).\n\n구독에는 두 종류가 있습니다.\n\n- **무조건**(`IPushForce`): `forceApprove(selector, target)`로 해당 셀렉터에 대한 모든 호출이 `target`으로 푸시됩니다. 가격 피드에 적합합니다.\n- **조건부**(`IPushFree`): `approve(selector, target, data)`는 호출이 `data`(예: 특정 `tokenId`)와 일치할 때만 푸시합니다. 그 밖의 모든 사람의 gas를 아낍니다.\n\n구독자는 `exec`와 `isLocked`가 있는 `IExec`를 구현합니다. 구독을 제거(`cancel` / `forceCancel`)하기 전에 발행자는 `isLocked`를 확인해야 하므로, 피드에 의존하는 구독자가 일방적으로 끊기지 않습니다. 발행자는 `renounceForceApprove` / `renounceForceCancel`로 무조건 구독자를 추가하거나 제거할 권한을 영구히 포기할 수도 있습니다.\n\n## 샘플 코드\n\n하나의 발행자만 신뢰하는 구독자:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\ninterface IExec {\n    function isLocked(bytes4 selector, bytes calldata data) external returns (bool);\n    function exec(bytes4 selector, bytes calldata data) external;\n}\n\ncontract PriceSubscriber is IExec {\n    address public immutable publisher;\n    bytes4 public immutable priceSelector;\n    uint256 public lastPrice;\n    uint256 public openPositions;\n\n    constructor(address pub, bytes4 sel) { publisher = pub; priceSelector = sel; }\n\n    function exec(bytes4 selector, bytes calldata data) external {\n        require(msg.sender == publisher, \"untrusted caller\"); // exec is public\n        require(selector == priceSelector, \"unexpected selector\");\n        lastPrice = abi.decode(data, (uint256));\n        // ... check positions and liquidate if needed\n    }\n\n    // Refuse unsubscription while positions depend on the feed.\n    function isLocked(bytes4, bytes calldata) external view returns (bool) {\n        return openPositions \u003e 0;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태: **Draft**.\n- 발행자의 호출자가 모든 구독자의 `exec`에 대한 gas를 냅니다. 구독자 목록이 길거나 비용이 크면 발행자의 함수가 비싸지거나 블록 gas limit을 넘을 수 있으므로, `approve`와 `forceApprove`에는 접근 제어가 필요합니다.\n- `exec`는 누구나 호출할 수 있으므로, 구독자는 `msg.sender`를 확인하고 데이터를 검증해야 합니다.\n- 신뢰할 수 없는 구독자를 호출하면 발행자로 되돌아오는 재진입 경로가 열립니다. 재진입 가드와 checks-effects-interactions 패턴을 사용하세요.\n- `isLocked`가 항상 `true`를 반환하는 구독자는 절대 제거할 수 없으므로, 발행자는 구독시키기 전에 이를 확인해야 합니다.\n"},"zh":{"lang":"zh","tldr":"一种面向合约的草案发布/订阅模式：发布者函数运行时，会在同一笔交易中对为该函数选择器注册的每个订阅者调用 exec()，以取代监视事件的链下 keeper。","tags":["oracle","pubsub","automation","hooks","defi"],"related":[1153,6551],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7615/","markdown":"## 它解决什么问题？\n\n当一个合约需要对另一个合约中发生的事情（价格更新、NFT 转移、投票结束）作出反应时，通常的答案是链下 keeper：一个机器人监视事件，并发送后续交易。这增加了对机器人的信任、两个步骤之间的延迟，以及状态不一致的窗口期。\n\nERC-7615 提议由源合约（**发布者**）在同一次调用内直接把更新推送给感兴趣的合约（**订阅者**）。规范中的例子：预言机把价格推送给借贷协议，由其当场清算；NFT 合约告知质押合约某个代币发生了移动，使其可以解除质押，让用户无需转移 NFT 就能质押；DAO 合约在投票结束时立即执行投票结果。\n\n## 它如何运作\n\n1. 发布者函数被调用，并运行内部的 `_push(selector, data)` 钩子。\n2. 发布者查找为该函数的 `selector` 注册的订阅者。\n3. 它对每个订阅者调用 `exec(selector, data)`。\n4. 订阅者据此行动，也可以选择调用发布者的 `inbox(selector)` 来获取更完整的数据（参考实现把它保存在 transient storage 中，见 [EIP-1153](/eip-1153/)）。\n\n订阅有两种：\n\n- **无条件**（`IPushForce`）：`forceApprove(selector, target)` 使对该选择器的每次调用都推送给 `target`。适合价格喂价。\n- **有条件**（`IPushFree`）：`approve(selector, target, data)` 只在调用与 `data`（例如某个特定的 `tokenId`）匹配时才推送。为其他所有人节省 gas。\n\n订阅者实现带有 `exec` 和 `isLocked` 的 `IExec`。在移除订阅（`cancel` / `forceCancel`）之前，发布者必须检查 `isLocked`，因此依赖该喂价的订阅者不会被单方面切断。发布者还可以通过 `renounceForceApprove` / `renounceForceCancel` 永久放弃添加或移除无条件订阅者的权力。\n\n## 示例代码\n\n一个只信任某一个发布者的订阅者：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\ninterface IExec {\n    function isLocked(bytes4 selector, bytes calldata data) external returns (bool);\n    function exec(bytes4 selector, bytes calldata data) external;\n}\n\ncontract PriceSubscriber is IExec {\n    address public immutable publisher;\n    bytes4 public immutable priceSelector;\n    uint256 public lastPrice;\n    uint256 public openPositions;\n\n    constructor(address pub, bytes4 sel) { publisher = pub; priceSelector = sel; }\n\n    function exec(bytes4 selector, bytes calldata data) external {\n        require(msg.sender == publisher, \"untrusted caller\"); // exec is public\n        require(selector == priceSelector, \"unexpected selector\");\n        lastPrice = abi.decode(data, (uint256));\n        // ... check positions and liquidate if needed\n    }\n\n    // Refuse unsubscription while positions depend on the feed.\n    function isLocked(bytes4, bytes calldata) external view returns (bool) {\n        return openPositions \u003e 0;\n    }\n}\n```\n\n## 需要注意\n\n- 状态：**Draft**。\n- 发布者的调用者要为每个订阅者的 `exec` 支付 gas。订阅者列表过长或开销过大，可能使发布者的函数变得昂贵，甚至超过区块 gas limit，所以 `approve` 和 `forceApprove` 需要访问控制。\n- `exec` 任何人都可以调用；订阅者必须验证 `msg.sender` 并校验数据。\n- 调用不受信任的订阅者会打开回到发布者的重入路径；请使用重入保护和 checks-effects-interactions 模式。\n- `isLocked` 始终返回 `true` 的订阅者永远无法被移除；发布者在订阅它之前应检查这一点。\n"}}}
