{"eip":2003,"title":"EVMC modules for implementations of precompiled contracts","description":"[EVMC] specifies a generic API for Ethereum execution engines. This EIP specifies a way of providing implementations of Ethereum precompiled contracts using the [EVMC VM API].","authors":["Paweł Bylica (@chfast)","Alex Beregszaszi (@axic)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2019-05-09","requires":[1352],"discussionsTo":"https://github.com/ethereum/evmc/issues/259","repo":"EIPs","label":"EIP-2003","officialUrl":"https://eips.ethereum.org/EIPS/eip-2003","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2003.md","url":"https://eips.huatuo.xyz/eip-2003/","tldr":{"en":"Specifies how to package Ethereum precompiled contracts as EVMC modules, so clients can load precompile implementations through the same plug-in API used for EVM engines.","ja":"Ethereum のプリコンパイルコントラクトを EVMC モジュールとしてパッケージ化する方法を定める。クライアントは EVM エンジンと同じプラグイン API でプリコンパイルの実装を読み込める。","ko":"이더리움 프리컴파일 컨트랙트를 EVMC 모듈로 패키징하는 방법을 정의한다. 클라이언트는 EVM 엔진과 같은 플러그인 API로 프리컴파일 구현을 불러올 수 있다.","zh":"规定如何将以太坊预编译合约打包为 EVMC 模块，让客户端可以通过与 EVM 引擎相同的插件 API 加载预编译实现。"},"tags":["evmc","precompiles","clients","interface"],"explainers":{"en":{"lang":"en","tldr":"Specifies how to package Ethereum precompiled contracts as EVMC modules, so clients can load precompile implementations through the same plug-in API used for EVM engines.","tags":["evmc","precompiles","clients","interface"],"related":[1352,1962],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2003/","markdown":"## What problem does it solve?\n\n[EVMC](https://github.com/ethereum/evmc) is a C API that lets an Ethereum client plug in an execution engine (for example evmone) as a separate module. Precompiled contracts, the special addresses that run native code for things like hashing and elliptic-curve math, were still hard-coded in each client.\n\nEIP-2003 defines how a precompile implementation can be shipped as an **EVMC module** too. A client that already speaks EVMC can then swap in a different or faster set of precompiles, or test new ones such as [EIP-1962](/eip-1962/), without changing its own code.\n\n## How it works\n\nA precompiles module is an ordinary EVMC VM (ABI version 6) with a few rules:\n\n1. It advertises the `EVMC_CAPABILITY_PRECOMPILES` capability in `get_capabilities()`.\n2. Its `execute()` first validates the request:\n   - the message kind is a plain call (`EVMC_CALL`);\n   - the destination is inside the precompile address range defined by [EIP-1352](/eip-1352/);\n   - no code is passed (`code == NULL`, `code_size == 0`).\n   If any check fails it returns `EVMC_REJECTED`.\n3. If a precompile exists at that address for the requested EVM revision, it computes the gas cost from the input. If the gas limit is too low it returns `EVMC_OUT_OF_GAS`; otherwise it runs, returning `EVMC_SUCCESS`, the output and the gas left.\n4. If no precompile exists there, it behaves like empty code: `EVMC_SUCCESS` with all gas returned.\n\nIt may also return `EVMC_FAILURE` (for example invalid input) or `EVMC_REVERT` if a precompile should not consume all gas.\n\nImportantly, the client **does not need to provide the EVMC Host interface**: the context argument is `NULL`, and the module must not touch it. Precompiles never need to read or change state, so this saves clients most of the work of a full EVMC integration.\n\n## Sample code\n\nIllustrative skeleton of a module's `execute` (field names as in EVMC ABI 6; later EVMC versions renamed some):\n\n```c\nstatic struct evmc_result execute(struct evmc_vm* vm,\n                                  const struct evmc_host_interface* host,\n                                  struct evmc_host_context* ctx,   /* NULL */\n                                  enum evmc_revision rev,\n                                  const struct evmc_message* msg,\n                                  const uint8_t* code, size_t code_size)\n{\n    struct evmc_result res = {.status_code = EVMC_REJECTED};\n    if (msg-\u003ekind != EVMC_CALL || code != NULL || code_size != 0 ||\n        !in_precompile_range(\u0026msg-\u003edestination))\n        return res;\n\n    const struct precompile* p = lookup(\u0026msg-\u003edestination, rev);\n    if (p == NULL) {                       /* behave like empty code */\n        res.status_code = EVMC_SUCCESS;\n        res.gas_left = msg-\u003egas;\n        return res;\n    }\n\n    int64_t cost = p-\u003egas_cost(msg-\u003einput_data, msg-\u003einput_size);\n    if (cost \u003e msg-\u003egas) { res.status_code = EVMC_OUT_OF_GAS; return res; }\n\n    res = p-\u003erun(msg-\u003einput_data, msg-\u003einput_size);  /* sets output */\n    res.gas_left = msg-\u003egas - cost;\n    return res;\n}\n```\n\n## Things to know\n\n- **Status: Stagnant.** It is an interface convention between client software components; it does not change consensus rules or anything visible on-chain.\n- It is tied to EVMC ABI version 6. Newer EVMC releases changed some field names and signatures, so check the version you build against.\n- [EIP-1352](/eip-1352/), which defines the precompile address range it relies on, is itself Stagnant.\n- EVMC ships a `evmc-vmtester` tool that can check a module for API compliance.\n"},"ja":{"lang":"ja","tldr":"Ethereum のプリコンパイルコントラクトを EVMC モジュールとしてパッケージ化する方法を定める。クライアントは EVM エンジンと同じプラグイン API でプリコンパイルの実装を読み込める。","tags":["evmc","precompiles","clients","interface"],"related":[1352,1962],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2003/","markdown":"## 何を解決するのか\n\n[EVMC](https://github.com/ethereum/evmc) は、Ethereum クライアントが実行エンジン（たとえば evmone）を別モジュールとして差し込めるようにする C API です。プリコンパイルコントラクト、つまりハッシュや楕円曲線演算などのネイティブコードを実行する特別なアドレスは、それでも各クライアントにハードコードされたままでした。\n\nEIP-2003 は、プリコンパイルの実装も **EVMC モジュール**として配布する方法を定義します。すでに EVMC に対応しているクライアントは、自分のコードを変更せずに、別の（あるいはより高速な）プリコンパイル群へ差し替えたり、[EIP-1962](/eip-1962/) のような新しいプリコンパイルを試したりできます。\n\n## 仕組み\n\nプリコンパイルモジュールは、いくつかのルールを持つ通常の EVMC VM（ABI バージョン 6）です。\n\n1. `get_capabilities()` で `EVMC_CAPABILITY_PRECOMPILES` ケイパビリティを通知します。\n2. `execute()` はまずリクエストを検証します。\n   - メッセージの種類が通常の呼び出し（`EVMC_CALL`）であること。\n   - 宛先が [EIP-1352](/eip-1352/) で定義されたプリコンパイルのアドレス範囲内であること。\n   - コードが渡されていないこと（`code == NULL`、`code_size == 0`）。\n   いずれかのチェックに失敗した場合は `EVMC_REJECTED` を返します。\n3. 要求された EVM リビジョンでそのアドレスにプリコンパイルが存在する場合、入力からガスコストを計算します。ガスリミットが足りなければ `EVMC_OUT_OF_GAS` を返し、足りていれば実行して `EVMC_SUCCESS`、出力、残りガスを返します。\n4. そのアドレスにプリコンパイルが存在しない場合は、空のコードと同じ挙動になります。つまりガスをすべて返して `EVMC_SUCCESS` を返します。\n\n`EVMC_FAILURE`（たとえば入力が不正な場合）や、プリコンパイルがガスをすべて消費すべきでない場合の `EVMC_REVERT` を返すこともできます。\n\n重要な点として、クライアントは **EVMC Host インターフェースを提供する必要がありません**。context 引数は `NULL` で、モジュールはそれに触れてはいけません。プリコンパイルはステートを読んだり変更したりする必要がないため、完全な EVMC 統合に伴う作業の大半をクライアントは省けます。\n\n## サンプルコード\n\nモジュールの `execute` の説明用スケルトン（フィールド名は EVMC ABI 6 のもので、以降の EVMC バージョンでは一部名前が変わっています）:\n\n```c\nstatic struct evmc_result execute(struct evmc_vm* vm,\n                                  const struct evmc_host_interface* host,\n                                  struct evmc_host_context* ctx,   /* NULL */\n                                  enum evmc_revision rev,\n                                  const struct evmc_message* msg,\n                                  const uint8_t* code, size_t code_size)\n{\n    struct evmc_result res = {.status_code = EVMC_REJECTED};\n    if (msg-\u003ekind != EVMC_CALL || code != NULL || code_size != 0 ||\n        !in_precompile_range(\u0026msg-\u003edestination))\n        return res;\n\n    const struct precompile* p = lookup(\u0026msg-\u003edestination, rev);\n    if (p == NULL) {                       /* behave like empty code */\n        res.status_code = EVMC_SUCCESS;\n        res.gas_left = msg-\u003egas;\n        return res;\n    }\n\n    int64_t cost = p-\u003egas_cost(msg-\u003einput_data, msg-\u003einput_size);\n    if (cost \u003e msg-\u003egas) { res.status_code = EVMC_OUT_OF_GAS; return res; }\n\n    res = p-\u003erun(msg-\u003einput_data, msg-\u003einput_size);  /* sets output */\n    res.gas_left = msg-\u003egas - cost;\n    return res;\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** これはクライアントのソフトウェアコンポーネント間のインターフェース規約であり、コンセンサスルールやオンチェーンで見えるものは変更しません。\n- EVMC ABI バージョン 6 に依存しています。新しい EVMC リリースでは一部のフィールド名やシグネチャが変わっているため、ビルド対象のバージョンを確認してください。\n- 依存しているプリコンパイルのアドレス範囲を定義する [EIP-1352](/eip-1352/) 自体も Stagnant です。\n- EVMC には、モジュールの API 準拠をチェックできる `evmc-vmtester` ツールが付属しています。\n"},"ko":{"lang":"ko","tldr":"이더리움 프리컴파일 컨트랙트를 EVMC 모듈로 패키징하는 방법을 정의한다. 클라이언트는 EVM 엔진과 같은 플러그인 API로 프리컴파일 구현을 불러올 수 있다.","tags":["evmc","precompiles","clients","interface"],"related":[1352,1962],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2003/","markdown":"## 어떤 문제를 해결하나요?\n\n[EVMC](https://github.com/ethereum/evmc)는 이더리움 클라이언트가 실행 엔진(예: evmone)을 별도 모듈로 끼워 넣을 수 있게 해 주는 C API입니다. 해싱이나 타원곡선 연산 같은 네이티브 코드를 실행하는 특수 주소인 프리컴파일 컨트랙트는 여전히 각 클라이언트에 하드코딩되어 있었습니다.\n\nEIP-2003은 프리컴파일 구현도 **EVMC 모듈**로 배포하는 방법을 정의합니다. 이미 EVMC를 지원하는 클라이언트는 자기 코드를 바꾸지 않고도 다른(또는 더 빠른) 프리컴파일 묶음으로 교체하거나, [EIP-1962](/eip-1962/) 같은 새 프리컴파일을 테스트할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n프리컴파일 모듈은 몇 가지 규칙을 따르는 일반 EVMC VM(ABI 버전 6)입니다.\n\n1. `get_capabilities()`에서 `EVMC_CAPABILITY_PRECOMPILES` 기능을 알립니다.\n2. `execute()`는 먼저 요청을 검증합니다.\n   - 메시지 종류가 일반 호출(`EVMC_CALL`)일 것\n   - 목적지가 [EIP-1352](/eip-1352/)에서 정의한 프리컴파일 주소 범위 안에 있을 것\n   - 코드가 전달되지 않을 것(`code == NULL`, `code_size == 0`)\n   검사 중 하나라도 실패하면 `EVMC_REJECTED`를 반환합니다.\n3. 요청된 EVM 리비전에서 해당 주소에 프리컴파일이 있으면 입력으로 가스 비용을 계산합니다. 가스 한도가 너무 낮으면 `EVMC_OUT_OF_GAS`를 반환하고, 그렇지 않으면 실행하여 `EVMC_SUCCESS`, 출력, 남은 가스를 반환합니다.\n4. 해당 주소에 프리컴파일이 없으면 빈 코드처럼 동작합니다. 즉 가스를 모두 돌려주고 `EVMC_SUCCESS`를 반환합니다.\n\n`EVMC_FAILURE`(예: 잘못된 입력)나, 프리컴파일이 가스를 전부 소모하면 안 되는 경우의 `EVMC_REVERT`를 반환할 수도 있습니다.\n\n중요한 점은 클라이언트가 **EVMC Host 인터페이스를 제공할 필요가 없다**는 것입니다. context 인자는 `NULL`이며 모듈은 이를 건드려서는 안 됩니다. 프리컴파일은 상태를 읽거나 바꿀 필요가 없으므로, 클라이언트는 전체 EVMC 통합에 드는 작업 대부분을 줄일 수 있습니다.\n\n## 샘플 코드\n\n모듈 `execute`의 설명용 뼈대 코드(필드 이름은 EVMC ABI 6 기준이며, 이후 EVMC 버전에서 일부 이름이 바뀌었습니다):\n\n```c\nstatic struct evmc_result execute(struct evmc_vm* vm,\n                                  const struct evmc_host_interface* host,\n                                  struct evmc_host_context* ctx,   /* NULL */\n                                  enum evmc_revision rev,\n                                  const struct evmc_message* msg,\n                                  const uint8_t* code, size_t code_size)\n{\n    struct evmc_result res = {.status_code = EVMC_REJECTED};\n    if (msg-\u003ekind != EVMC_CALL || code != NULL || code_size != 0 ||\n        !in_precompile_range(\u0026msg-\u003edestination))\n        return res;\n\n    const struct precompile* p = lookup(\u0026msg-\u003edestination, rev);\n    if (p == NULL) {                       /* behave like empty code */\n        res.status_code = EVMC_SUCCESS;\n        res.gas_left = msg-\u003egas;\n        return res;\n    }\n\n    int64_t cost = p-\u003egas_cost(msg-\u003einput_data, msg-\u003einput_size);\n    if (cost \u003e msg-\u003egas) { res.status_code = EVMC_OUT_OF_GAS; return res; }\n\n    res = p-\u003erun(msg-\u003einput_data, msg-\u003einput_size);  /* sets output */\n    res.gas_left = msg-\u003egas - cost;\n    return res;\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 클라이언트 소프트웨어 구성 요소 사이의 인터페이스 규약이며, 합의 규칙이나 온체인에서 보이는 것은 바꾸지 않습니다.\n- EVMC ABI 버전 6에 묶여 있습니다. 최신 EVMC 릴리스에서는 일부 필드 이름과 시그니처가 바뀌었으므로, 빌드 대상 버전을 확인하세요.\n- 이 EIP가 의존하는 프리컴파일 주소 범위를 정의한 [EIP-1352](/eip-1352/) 자체도 Stagnant입니다.\n- EVMC에는 모듈의 API 준수 여부를 검사할 수 있는 `evmc-vmtester` 도구가 포함되어 있습니다.\n"},"zh":{"lang":"zh","tldr":"规定如何将以太坊预编译合约打包为 EVMC 模块，让客户端可以通过与 EVM 引擎相同的插件 API 加载预编译实现。","tags":["evmc","precompiles","clients","interface"],"related":[1352,1962],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2003/","markdown":"## 它解决什么问题？\n\n[EVMC](https://github.com/ethereum/evmc) 是一套 C API，允许以太坊客户端把执行引擎（例如 evmone）作为独立模块接入。预编译合约，即运行哈希、椭圆曲线运算等原生代码的特殊地址，却仍然硬编码在各个客户端中。\n\nEIP-2003 定义了如何把预编译实现也作为 **EVMC 模块**发布。这样，已经支持 EVMC 的客户端无需修改自身代码，就可以换用另一套（或更快的）预编译实现，或者测试 [EIP-1962](/eip-1962/) 等新的预编译。\n\n## 它如何运作\n\n预编译模块是一个普通的 EVMC VM（ABI 版本 6），并遵循几条规则：\n\n1. 在 `get_capabilities()` 中声明 `EVMC_CAPABILITY_PRECOMPILES` 能力。\n2. 其 `execute()` 首先校验请求：\n   - 消息类型是普通调用（`EVMC_CALL`）；\n   - 目标地址位于 [EIP-1352](/eip-1352/) 定义的预编译地址范围内；\n   - 不传入代码（`code == NULL`，`code_size == 0`）。\n   任何一项检查失败，都返回 `EVMC_REJECTED`。\n3. 如果在请求的 EVM 版本下该地址存在预编译，就根据输入计算 gas 成本。若 gas 上限过低，返回 `EVMC_OUT_OF_GAS`；否则执行并返回 `EVMC_SUCCESS`、输出和剩余 gas。\n4. 如果该地址没有预编译，则表现得像空代码：返回 `EVMC_SUCCESS`，并退回全部 gas。\n\n它也可以返回 `EVMC_FAILURE`（例如输入无效），或在预编译不应消耗全部 gas 时返回 `EVMC_REVERT`。\n\n重要的是，客户端**无需提供 EVMC Host 接口**：context 参数为 `NULL`，模块不得访问它。预编译从不需要读取或修改状态，因此客户端可以省去完整 EVMC 集成的大部分工作。\n\n## 示例代码\n\n模块 `execute` 的示意骨架（字段名为 EVMC ABI 6 中的名称，后续 EVMC 版本重命名了部分字段）：\n\n```c\nstatic struct evmc_result execute(struct evmc_vm* vm,\n                                  const struct evmc_host_interface* host,\n                                  struct evmc_host_context* ctx,   /* NULL */\n                                  enum evmc_revision rev,\n                                  const struct evmc_message* msg,\n                                  const uint8_t* code, size_t code_size)\n{\n    struct evmc_result res = {.status_code = EVMC_REJECTED};\n    if (msg-\u003ekind != EVMC_CALL || code != NULL || code_size != 0 ||\n        !in_precompile_range(\u0026msg-\u003edestination))\n        return res;\n\n    const struct precompile* p = lookup(\u0026msg-\u003edestination, rev);\n    if (p == NULL) {                       /* behave like empty code */\n        res.status_code = EVMC_SUCCESS;\n        res.gas_left = msg-\u003egas;\n        return res;\n    }\n\n    int64_t cost = p-\u003egas_cost(msg-\u003einput_data, msg-\u003einput_size);\n    if (cost \u003e msg-\u003egas) { res.status_code = EVMC_OUT_OF_GAS; return res; }\n\n    res = p-\u003erun(msg-\u003einput_data, msg-\u003einput_size);  /* sets output */\n    res.gas_left = msg-\u003egas - cost;\n    return res;\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 它是客户端软件组件之间的接口约定，不改变共识规则，也不改变链上任何可见内容。\n- 它绑定于 EVMC ABI 版本 6。较新的 EVMC 版本更改了部分字段名和签名，请确认你所构建的版本。\n- 它所依赖的预编译地址范围由 [EIP-1352](/eip-1352/) 定义，而该 EIP 本身也是 Stagnant 状态。\n- EVMC 附带 `evmc-vmtester` 工具，可用于检查模块是否符合 API 规范。\n"}}}
