{"eip":1154,"title":"Oracle Interface","description":"A standard interface for oracles.","authors":["Alan Lu (@cag)"],"status":"Withdrawn","type":"Standards Track","category":"ERC","created":"2018-06-13","discussionsTo":"https://github.com/ethereum/EIPs/issues/1161","repo":"ERCs","label":"ERC-1154","officialUrl":"https://eips.ethereum.org/EIPS/eip-1154","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1154.md","url":"https://eips.huatuo.xyz/eip-1154/","tldr":{"en":"A withdrawn proposal for one minimal oracle interface, where an oracle pushes an (id, result) report into a consumer contract, so oracle providers could be swapped without rewriting the consumer.","ja":"オラクルが (id, result) のレポートをコンシューマーコントラクトにプッシュする、最小限のオラクルインターフェースを 1 つ定める撤回済みの提案。コンシューマーを書き直さずにオラクル提供者を差し替えられるようにする。","ko":"오라클이 (id, result) 보고를 소비자 컨트랙트로 푸시하는 최소한의 오라클 인터페이스 하나를 제안했다가 철회된 제안. 소비자를 다시 쓰지 않고도 오라클 제공자를 바꿀 수 있게 하려는 것이었다.","zh":"一项已撤回的提案，旨在定义一个最小化的预言机接口：预言机把 (id, result) 报告推送给消费者合约，这样无需重写消费者就能更换预言机提供方。"},"tags":["oracle","interface","prediction-markets","withdrawn"],"explainers":{"en":{"lang":"en","tldr":"A withdrawn proposal for one minimal oracle interface, where an oracle pushes an (id, result) report into a consumer contract, so oracle providers could be swapped without rewriting the consumer.","tags":["oracle","interface","prediction-markets","withdrawn"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1154/","markdown":"## What problem does it solve?\n\nSmart contracts cannot see the outside world, so they rely on oracles to report things like match results, prices or votes. In 2018 every oracle system used its own callback name and semantics (for example Oraclize's `__callback` or Chainlink's arbitrary callback names). A contract written for one oracle could not easily switch to another without adapters.\n\nERC-1154 tried to standardise the part that is the same everywhere: an oracle delivering a result for a specific question. The value of each oracle system lies in *how* it reaches an answer, not in the function name used to deliver it.\n\n## How it works\n\nThe spec defines a few terms: an **oracle** (any Ethereum account that reports data), an **oracle consumer** (the contract receiving it), an **ID** (what is being asked) and a **result** (the answer, as raw bytes).\n\nThe main interface is push-based: the oracle calls the consumer.\n\n- `receiveResult(bytes32 id, bytes result)` is implemented by the consumer.\n- It must revert if the caller is not an oracle authorised for that `id`.\n- It must revert if a result for that `id` was already received, so results are immutable.\n- Oracle and consumer agree off-band on how `result` is encoded, for example with `abi.encode` / `abi.decode`.\n\nThe spec also documents an alternative pull-based interface, `resultFor(bytes32 id)`, which must revert until a result exists and must then always return the same value. Either style can be adapted to the other with one extra contract and one extra transaction.\n\nIDs and results are intentionally unstructured. For time-series data the ID can encode both \"what\" and \"when\".\n\n## Sample code\n\nA consumer that accepts one result per question from a single trusted oracle:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface OracleConsumer {\n    function receiveResult(bytes32 id, bytes calldata result) external;\n}\n\ncontract BinaryMarket is OracleConsumer {\n    address public immutable oracle;\n    mapping(bytes32 =\u003e bool) public resolved;\n    mapping(bytes32 =\u003e bool) public outcome;\n\n    constructor(address _oracle) { oracle = _oracle; }\n\n    function receiveResult(bytes32 id, bytes calldata result) external {\n        require(msg.sender == oracle, \"unauthorized oracle\");\n        require(!resolved[id], \"already resolved\");\n        resolved[id] = true;\n        outcome[id] = abi.decode(result, (bool)); // codec agreed with the oracle\n    }\n}\n```\n\n## Things to know\n\n- Status is **Withdrawn**. It is not a standard to build against, though the push/pull discussion is still a useful reference.\n- Today most on-chain price data is read through provider-specific interfaces rather than a shared ERC; no common oracle standard replaced this one.\n- In the push model the consumer enforces immutability itself. In the pull model you must trust the oracle contract to never change an answer, or check it yourself.\n- When one account (or a multisig) alone decides an outcome, the spec notes that no separate oracle contract is needed: that account can call `receiveResult` directly.\n"},"ja":{"lang":"ja","tldr":"オラクルが (id, result) のレポートをコンシューマーコントラクトにプッシュする、最小限のオラクルインターフェースを 1 つ定める撤回済みの提案。コンシューマーを書き直さずにオラクル提供者を差し替えられるようにする。","tags":["oracle","interface","prediction-markets","withdrawn"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1154/","markdown":"## 何を解決するのか\n\nスマートコントラクトは外の世界を見ることができないため、試合結果、価格、投票結果などの報告をオラクルに頼ります。2018 年当時、すべてのオラクルシステムが独自のコールバック名とセマンティクスを使っていました（たとえば Oraclize の `__callback` や、Chainlink の任意のコールバック名）。あるオラクル向けに書かれたコントラクトは、アダプターなしでは別のオラクルに簡単に切り替えられませんでした。\n\nERC-1154 は、どこでも共通している部分、つまりオラクルが特定の質問に対する結果を届けるという部分を標準化しようとしました。各オラクルシステムの価値は、結果を届ける関数名ではなく、答えに*どう*到達するかにあります。\n\n## 仕組み\n\n仕様はいくつかの用語を定義しています。**オラクル**（データを報告する任意の Ethereum アカウント）、**オラクルコンシューマー**（それを受け取るコントラクト）、**ID**（何が問われているか）、**結果**（答え。生の bytes）です。\n\n主要なインターフェースはプッシュ型で、オラクルがコンシューマーを呼び出します。\n\n- `receiveResult(bytes32 id, bytes result)` はコンシューマーが実装します。\n- 呼び出し元がその `id` に対して認可されたオラクルでない場合は、リバートしなければなりません。\n- その `id` の結果をすでに受け取っている場合もリバートしなければならず、結果は不変です。\n- オラクルとコンシューマーは、`result` のエンコード方法（たとえば `abi.encode` / `abi.decode`）をオフバンドで取り決めます。\n\n仕様には代替のプル型インターフェース `resultFor(bytes32 id)` も記載されています。これは結果が存在するまでリバートし、その後は常に同じ値を返さなければなりません。どちらの方式も、追加のコントラクト 1 つと追加のトランザクション 1 回で、もう一方に適合させられます。\n\nID と結果は意図的に構造化されていません。時系列データの場合、ID に「何を」と「いつ」の両方をエンコードできます。\n\n## サンプルコード\n\n信頼できる単一のオラクルから、質問ごとに 1 つの結果を受け入れるコンシューマー:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface OracleConsumer {\n    function receiveResult(bytes32 id, bytes calldata result) external;\n}\n\ncontract BinaryMarket is OracleConsumer {\n    address public immutable oracle;\n    mapping(bytes32 =\u003e bool) public resolved;\n    mapping(bytes32 =\u003e bool) public outcome;\n\n    constructor(address _oracle) { oracle = _oracle; }\n\n    function receiveResult(bytes32 id, bytes calldata result) external {\n        require(msg.sender == oracle, \"unauthorized oracle\");\n        require(!resolved[id], \"already resolved\");\n        resolved[id] = true;\n        outcome[id] = abi.decode(result, (bool)); // codec agreed with the oracle\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Withdrawn** です。これに対して構築すべき標準ではありませんが、プッシュ型とプル型の議論は今も参考になります。\n- 今日のオンチェーン価格データのほとんどは、共有 ERC ではなく、提供者固有のインターフェースを通じて読み取られます。これに代わる共通のオラクル標準は登場していません。\n- プッシュ型では、コンシューマー自身が不変性を強制します。プル型では、オラクルコントラクトが答えを決して変更しないことを信頼するか、自分で確認する必要があります。\n- 結果を 1 つのアカウント（またはマルチシグ）だけが決める場合、仕様は別個のオラクルコントラクトは不要だと述べています。そのアカウントが `receiveResult` を直接呼び出せます。\n"},"ko":{"lang":"ko","tldr":"오라클이 (id, result) 보고를 소비자 컨트랙트로 푸시하는 최소한의 오라클 인터페이스 하나를 제안했다가 철회된 제안. 소비자를 다시 쓰지 않고도 오라클 제공자를 바꿀 수 있게 하려는 것이었다.","tags":["oracle","interface","prediction-markets","withdrawn"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1154/","markdown":"## 어떤 문제를 해결하나요?\n\n스마트 컨트랙트는 바깥 세상을 볼 수 없으므로, 경기 결과, 가격, 투표 같은 것을 보고하는 데 오라클에 의존합니다. 2018년에는 모든 오라클 시스템이 자기만의 콜백 이름과 의미를 사용했습니다(예: Oraclize의 `__callback`, Chainlink의 임의 콜백 이름). 한 오라클을 위해 작성된 컨트랙트는 어댑터 없이는 다른 오라클로 쉽게 바꿀 수 없었습니다.\n\nERC-1154는 어디서나 같은 부분, 즉 오라클이 특정 질문에 대한 결과를 전달하는 부분을 표준화하려 했습니다. 각 오라클 시스템의 가치는 답을 전달하는 데 쓰는 함수 이름이 아니라 답에 *어떻게* 도달하느냐에 있습니다.\n\n## 어떻게 동작하나요?\n\n명세는 몇 가지 용어를 정의합니다. **오라클**(데이터를 보고하는 모든 이더리움 계정), **오라클 소비자**(이를 받는 컨트랙트), **ID**(무엇을 묻는지), **결과**(답, 원시 바이트)입니다.\n\n주요 인터페이스는 푸시 방식입니다. 오라클이 소비자를 호출합니다.\n\n- `receiveResult(bytes32 id, bytes result)`는 소비자가 구현합니다.\n- 호출자가 해당 `id`에 대해 권한이 있는 오라클이 아니면 반드시 리버트해야 합니다.\n- 해당 `id`의 결과를 이미 받았다면 반드시 리버트해야 하므로, 결과는 불변입니다.\n- 오라클과 소비자는 `result`를 어떻게 인코딩할지를 오프밴드로 합의합니다. 예를 들어 `abi.encode` / `abi.decode`를 씁니다.\n\n명세에는 대안인 풀 방식 인터페이스 `resultFor(bytes32 id)`도 기록되어 있습니다. 이는 결과가 생기기 전까지 리버트해야 하고, 그 뒤에는 항상 같은 값을 반환해야 합니다. 어느 쪽 방식이든 컨트랙트 하나와 트랜잭션 하나를 추가하면 다른 쪽에 맞출 수 있습니다.\n\nID와 결과는 의도적으로 구조화되어 있지 않습니다. 시계열 데이터의 경우 ID에 \"무엇\"과 \"언제\"를 모두 인코딩할 수 있습니다.\n\n## 샘플 코드\n\n신뢰하는 단일 오라클로부터 질문마다 결과 하나만 받는 소비자:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface OracleConsumer {\n    function receiveResult(bytes32 id, bytes calldata result) external;\n}\n\ncontract BinaryMarket is OracleConsumer {\n    address public immutable oracle;\n    mapping(bytes32 =\u003e bool) public resolved;\n    mapping(bytes32 =\u003e bool) public outcome;\n\n    constructor(address _oracle) { oracle = _oracle; }\n\n    function receiveResult(bytes32 id, bytes calldata result) external {\n        require(msg.sender == oracle, \"unauthorized oracle\");\n        require(!resolved[id], \"already resolved\");\n        resolved[id] = true;\n        outcome[id] = abi.decode(result, (bool)); // codec agreed with the oracle\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Withdrawn**입니다. 이를 기준으로 구축할 표준은 아니지만, 푸시/풀 논의는 여전히 유용한 참고 자료입니다.\n- 오늘날 대부분의 온체인 가격 데이터는 공유 ERC가 아니라 제공자별 인터페이스로 읽습니다. 이를 대체한 공통 오라클 표준은 없습니다.\n- 푸시 모델에서는 소비자가 불변성을 직접 강제합니다. 풀 모델에서는 오라클 컨트랙트가 답을 절대 바꾸지 않을 것이라고 신뢰하거나 직접 확인해야 합니다.\n- 한 계정(또는 멀티시그) 혼자서 결과를 결정하는 경우, 명세는 별도의 오라클 컨트랙트가 필요 없다고 말합니다. 그 계정이 `receiveResult`를 직접 호출하면 됩니다.\n"},"zh":{"lang":"zh","tldr":"一项已撤回的提案，旨在定义一个最小化的预言机接口：预言机把 (id, result) 报告推送给消费者合约，这样无需重写消费者就能更换预言机提供方。","tags":["oracle","interface","prediction-markets","withdrawn"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1154/","markdown":"## 它解决什么问题？\n\n智能合约看不到外部世界，因此依赖预言机来报告比赛结果、价格或投票等信息。2018 年，每个预言机系统都使用自己的回调名称和语义（例如 Oraclize 的 `__callback`，或 Chainlink 的任意回调名称）。为某个预言机编写的合约，没有适配器就很难切换到另一个预言机。\n\nERC-1154 试图把各处都相同的那部分标准化：预言机为某个特定问题交付结果。每个预言机系统的价值在于它*如何*得出答案，而不在于用来交付答案的函数名。\n\n## 它如何运作\n\n规范定义了几个术语：**预言机**（任何报告数据的以太坊账户）、**预言机消费者**（接收数据的合约）、**ID**（所问的内容）和**结果**（答案，以原始字节表示）。\n\n主要接口是推送式的：预言机调用消费者。\n\n- `receiveResult(bytes32 id, bytes result)` 由消费者实现。\n- 如果调用者不是被授权报告该 `id` 的预言机，必须回滚。\n- 如果该 `id` 的结果已经收到过，必须回滚，因此结果是不可变的。\n- 预言机和消费者在链下约定 `result` 的编码方式，例如使用 `abi.encode` / `abi.decode`。\n\n规范还记录了另一种拉取式接口 `resultFor(bytes32 id)`，在结果出现之前它必须回滚，之后必须始终返回相同的值。任意一种风格都可以借助一个额外的合约和一笔额外的交易适配为另一种。\n\nID 和结果有意不加结构。对于时间序列数据，ID 可以同时编码\"什么\"和\"何时\"。\n\n## 示例代码\n\n一个只接受单个受信任预言机、每个问题只接受一个结果的消费者：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface OracleConsumer {\n    function receiveResult(bytes32 id, bytes calldata result) external;\n}\n\ncontract BinaryMarket is OracleConsumer {\n    address public immutable oracle;\n    mapping(bytes32 =\u003e bool) public resolved;\n    mapping(bytes32 =\u003e bool) public outcome;\n\n    constructor(address _oracle) { oracle = _oracle; }\n\n    function receiveResult(bytes32 id, bytes calldata result) external {\n        require(msg.sender == oracle, \"unauthorized oracle\");\n        require(!resolved[id], \"already resolved\");\n        resolved[id] = true;\n        outcome[id] = abi.decode(result, (bool)); // codec agreed with the oracle\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Withdrawn**。它不是可以据以构建的标准，不过关于推送与拉取的讨论仍然是有用的参考。\n- 如今大多数链上价格数据是通过各提供方专有的接口读取的，而不是通过共享的 ERC；没有哪个通用的预言机标准取代了它。\n- 在推送模型中，消费者自行保证不可变性。在拉取模型中，你必须相信预言机合约永远不会更改答案，或者自己检查。\n- 当结果仅由一个账户（或一个多签）决定时，规范指出不需要单独的预言机合约：该账户可以直接调用 `receiveResult`。\n"}}}
