{"eip":2009,"title":"Compliance Service","description":"This EIP proposes a service for decentralized compliance checks for regulated tokens.","authors":["Daniel Lehrner \u003cdaniel@io.builders\u003e"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2019-05-09","requires":[1066],"discussionsTo":"https://github.com/ethereum/EIPs/issues/2022","repo":"ERCs","label":"ERC-2009","officialUrl":"https://eips.ethereum.org/EIPS/eip-2009","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2009.md","url":"https://eips.huatuo.xyz/eip-2009/","tldr":{"en":"A stagnant proposal for a shared on-chain compliance service that regulated tokens query before every transfer, mint or burn, so KYC/AML-style rules run in the same transaction instead of an off-chain approval step.","ja":"停滞中の提案。規制対象トークンが転送・発行・焼却のたびに問い合わせる共有オンチェーンのコンプライアンスサービスを定め、KYC/AML 型のルールをオフチェーンの承認手続きではなく同じトランザクション内で実行する。","ko":"정체 상태인 제안. 규제 대상 토큰이 전송·발행·소각 전에 매번 조회하는 공유 온체인 컴플라이언스 서비스를 정의해, KYC/AML 방식의 규칙을 오프체인 승인 단계 대신 같은 트랜잭션 안에서 실행한다.","zh":"一项已停滞的提案：定义一个共享的链上合规服务，受监管代币在每次转账、铸造或销毁前都会查询它，使 KYC/AML 类规则在同一笔交易中执行，而不是依赖链下审批步骤。"},"tags":["compliance","security-token","regulated","kyc","stagnant"],"explainers":{"en":{"lang":"en","tldr":"A stagnant proposal for a shared on-chain compliance service that regulated tokens query before every transfer, mint or burn, so KYC/AML-style rules run in the same transaction instead of an off-chain approval step.","tags":["compliance","security-token","regulated","kyc","stagnant"],"related":[1462,1066,777,1444,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2009/","markdown":"## What problem does it solve?\n\nRegulated tokens (securities, e-money and similar) must enforce legal rules such as KYC and anti-money-laundering limits. When those checks happen off chain, a transfer becomes a two-step process: request, then wait for an operator to approve. That is slower and reintroduces a central gatekeeper.\n\n[ERC-1462](/eip-1462/) already proposed `checkTransferAllowed`-style functions but did not say how to implement them. ERC-2009 defines a **Compliance Service** contract that holds the rules and can be shared by many tokens, for example all tokens under one jurisdiction, so checks run fully on chain inside the token transfer.\n\n## How it works\n\nActors: the **token** (calls the service), the **token holder** (the account being checked) and an optional **operator** authorised to update data on a token's behalf.\n\n1. **Checks** (view): `checkTransferAllowed`, `checkTransferFromAllowed`, `checkMintAllowed`, `checkBurnAllowed`. They return a one-byte status code following [ERC-1066](/eip-1066/): `0x11` *Allowed* or `0x10` *Disallowed*, or an issuer-specific code with the same meaning. The token must revert unless the result means *allowed*.\n2. **Accumulated updates**: `updateTransferAccumulated`, `updateMintAccumulated`, `updateBurnAccumulated` are called in the same transaction as the action. They record running totals (e.g. volume per period) and revert if a rule would be violated. The rules themselves are left to the implementer.\n3. **Token registry**: tokens are identified by a `bytes32 tokenId`, not their address. `addToken`, `replaceToken` and `removeToken` manage the mapping, so a token can upgrade its contract and keep its accumulated history.\n4. **Operators**: `authorizeAccumulatedOperator`, `revokeAccumulatedOperator`, `isAccumulatedOperatorFor`, named after [ERC-777](/eip-777/) operators.\n\nNo event is emitted on updates, since the token's own `Transfer` already marks them.\n\n## Sample code\n\nA token consulting the service inside `transfer` (simplified):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface ICompliantService {\n    function checkTransferAllowed(bytes32 tokenId, address from, address to, uint256 value)\n        external view returns (bytes1);\n    function updateTransferAccumulated(bytes32 tokenId, address from, address to, uint256 value)\n        external;\n}\n\ncontract RegulatedToken {\n    bytes1 private constant ALLOWED = 0x11; // ERC-1066 \"Allowed\"\n\n    ICompliantService public immutable compliance;\n    bytes32 public immutable tokenId;\n    mapping(address =\u003e uint256) public balanceOf;\n\n    constructor(ICompliantService svc, bytes32 id) { compliance = svc; tokenId = id; }\n\n    function transfer(address to, uint256 value) external returns (bool) {\n        require(\n            compliance.checkTransferAllowed(tokenId, msg.sender, to, value) == ALLOWED,\n            \"transfer not allowed\"\n        );\n        compliance.updateTransferAccumulated(tokenId, msg.sender, to, value); // reverts on violation\n        balanceOf[msg.sender] -= value;\n        balanceOf[to] += value;\n        return true;\n    }\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**.\n- The spec uses the old Solidity `byte` type; use `bytes1` today. It also names the revocation event both `RevokedAccumulatedOperator` (interface) and `RevokedHoldOperator` (event list); the interface name is the consistent one.\n- Whoever can add, replace or remove tokens and change rules in the service effectively controls every token using it. The spec leaves those permissions to the implementer.\n- Localised error messages can be added with [ERC-1444](/eip-1444/) on top of ERC-1066 codes.\n- The standard provides mechanics only. Whether a given rule set satisfies any particular regulation is a legal question to review with qualified counsel.\n"},"ja":{"lang":"ja","tldr":"停滞中の提案。規制対象トークンが転送・発行・焼却のたびに問い合わせる共有オンチェーンのコンプライアンスサービスを定め、KYC/AML 型のルールをオフチェーンの承認手続きではなく同じトランザクション内で実行する。","tags":["compliance","security-token","regulated","kyc","stagnant"],"related":[1462,1066,777,1444,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2009/","markdown":"## 何を解決するのか\n\n規制対象のトークン（証券、電子マネーなど）は、KYC やマネーロンダリング対策の上限といった法的ルールを守らなければなりません。これらのチェックをオフチェーンで行うと、送金は「申請してから運営者の承認を待つ」という 2 段階の手順になります。遅くなるうえ、中央集権的なゲートキーパーが再び必要になります。\n\n[ERC-1462](/eip-1462/) はすでに `checkTransferAllowed` 型の関数を提案していましたが、その実装方法は示していませんでした。ERC-2009 は、ルールを保持し、複数のトークン（たとえば同一の法域に属するすべてのトークン）で共有できる **Compliance Service** コントラクトを定義します。これにより、チェックはトークンの転送内で完全にオンチェーンで実行されます。\n\n## 仕組み\n\n登場するのは、**トークン**（サービスを呼び出す側）、**トークン保有者**（チェック対象のアカウント）、そしてトークンに代わってデータを更新する権限を持つ任意の **オペレーター** です。\n\n1. **チェック**（view）: `checkTransferAllowed`、`checkTransferFromAllowed`、`checkMintAllowed`、`checkBurnAllowed`。[ERC-1066](/eip-1066/) に従う 1 バイトのステータスコードを返します。`0x11` *Allowed*（許可）、`0x10` *Disallowed*（不許可）、または同じ意味を持つ発行者固有のコードです。トークンは、結果が *allowed* を意味しない限り revert しなければなりません。\n2. **累積値の更新**: `updateTransferAccumulated`、`updateMintAccumulated`、`updateBurnAccumulated` は、アクションと同じトランザクション内で呼び出されます。累計値（たとえば期間ごとの取引量）を記録し、ルール違反になる場合は revert します。ルール自体は実装者に委ねられています。\n3. **トークンレジストリ**: トークンはアドレスではなく `bytes32 tokenId` で識別されます。`addToken`、`replaceToken`、`removeToken` がこの対応を管理するため、トークンはコントラクトをアップグレードしても累積履歴を引き継げます。\n4. **オペレーター**: `authorizeAccumulatedOperator`、`revokeAccumulatedOperator`、`isAccumulatedOperatorFor`。名前は [ERC-777](/eip-777/) のオペレーターに由来します。\n\n更新時にイベントは発行されません。トークン自身の `Transfer` がすでにその目印になっているためです。\n\n## サンプルコード\n\n`transfer` の中でサービスを参照するトークン（簡略版）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface ICompliantService {\n    function checkTransferAllowed(bytes32 tokenId, address from, address to, uint256 value)\n        external view returns (bytes1);\n    function updateTransferAccumulated(bytes32 tokenId, address from, address to, uint256 value)\n        external;\n}\n\ncontract RegulatedToken {\n    bytes1 private constant ALLOWED = 0x11; // ERC-1066 \"Allowed\"\n\n    ICompliantService public immutable compliance;\n    bytes32 public immutable tokenId;\n    mapping(address =\u003e uint256) public balanceOf;\n\n    constructor(ICompliantService svc, bytes32 id) { compliance = svc; tokenId = id; }\n\n    function transfer(address to, uint256 value) external returns (bool) {\n        require(\n            compliance.checkTransferAllowed(tokenId, msg.sender, to, value) == ALLOWED,\n            \"transfer not allowed\"\n        );\n        compliance.updateTransferAccumulated(tokenId, msg.sender, to, value); // reverts on violation\n        balanceOf[msg.sender] -= value;\n        balanceOf[to] += value;\n        return true;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant**（停滞）です。\n- 仕様は古い Solidity の `byte` 型を使っています。現在は `bytes1` を使ってください。また、取り消しイベントの名前が `RevokedAccumulatedOperator`（インターフェース）と `RevokedHoldOperator`（イベント一覧）の 2 通りで書かれています。インターフェース側の名前のほうが一貫しています。\n- サービス内でトークンの追加・置換・削除やルールの変更ができる人は、そのサービスを使うすべてのトークンを事実上支配します。仕様はこれらの権限の扱いを実装者に委ねています。\n- ローカライズされたエラーメッセージは、ERC-1066 のコードの上に [ERC-1444](/eip-1444/) を重ねて追加できます。\n- この標準が提供するのは仕組みだけです。あるルールセットが特定の規制を満たすかどうかは法的な問題であり、資格を持つ専門家と一緒に確認してください。\n"},"ko":{"lang":"ko","tldr":"정체 상태인 제안. 규제 대상 토큰이 전송·발행·소각 전에 매번 조회하는 공유 온체인 컴플라이언스 서비스를 정의해, KYC/AML 방식의 규칙을 오프체인 승인 단계 대신 같은 트랜잭션 안에서 실행한다.","tags":["compliance","security-token","regulated","kyc","stagnant"],"related":[1462,1066,777,1444,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2009/","markdown":"## 어떤 문제를 해결하나요?\n\n규제 대상 토큰(증권, 전자화폐 등)은 KYC나 자금세탁방지 한도 같은 법적 규칙을 지켜야 합니다. 이런 검사를 오프체인에서 하면 전송이 요청한 뒤 운영자의 승인을 기다리는 두 단계 과정이 됩니다. 느릴 뿐 아니라 중앙화된 관문 역할이 다시 생깁니다.\n\n[ERC-1462](/eip-1462/)는 이미 `checkTransferAllowed` 방식의 함수를 제안했지만 구현 방법은 다루지 않았습니다. ERC-2009는 규칙을 보관하며 여러 토큰(예: 한 관할권의 모든 토큰)이 공유할 수 있는 **Compliance Service** 컨트랙트를 정의합니다. 그래서 검사가 토큰 전송 안에서 완전히 온체인으로 실행됩니다.\n\n## 어떻게 동작하나요?\n\n참여자는 **토큰**(서비스를 호출), **토큰 보유자**(검사 대상 계정), 그리고 토큰을 대신해 데이터를 갱신할 권한이 있는 선택적 **오퍼레이터**입니다.\n\n1. **검사**(view): `checkTransferAllowed`, `checkTransferFromAllowed`, `checkMintAllowed`, `checkBurnAllowed`. [ERC-1066](/eip-1066/)을 따르는 1바이트 상태 코드를 반환합니다. `0x11` *Allowed*(허용), `0x10` *Disallowed*(불허) 또는 같은 의미의 발행자 고유 코드입니다. 결과가 *allowed*를 의미하지 않으면 토큰은 반드시 revert해야 합니다.\n2. **누적값 갱신**: `updateTransferAccumulated`, `updateMintAccumulated`, `updateBurnAccumulated`는 해당 동작과 같은 트랜잭션에서 호출됩니다. 누적 합계(예: 기간별 거래량)를 기록하고, 규칙을 위반하게 되면 revert합니다. 규칙 자체는 구현자에게 맡겨져 있습니다.\n3. **토큰 레지스트리**: 토큰은 주소가 아니라 `bytes32 tokenId`로 식별됩니다. `addToken`, `replaceToken`, `removeToken`이 이 매핑을 관리하므로, 토큰은 컨트랙트를 업그레이드해도 누적 이력을 유지할 수 있습니다.\n4. **오퍼레이터**: `authorizeAccumulatedOperator`, `revokeAccumulatedOperator`, `isAccumulatedOperatorFor`. 이름은 [ERC-777](/eip-777/)의 오퍼레이터에서 따왔습니다.\n\n갱신 시에는 이벤트가 발생하지 않습니다. 토큰 자체의 `Transfer`가 이미 그 동작을 표시하기 때문입니다.\n\n## 샘플 코드\n\n`transfer` 안에서 서비스를 조회하는 토큰(단순화):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface ICompliantService {\n    function checkTransferAllowed(bytes32 tokenId, address from, address to, uint256 value)\n        external view returns (bytes1);\n    function updateTransferAccumulated(bytes32 tokenId, address from, address to, uint256 value)\n        external;\n}\n\ncontract RegulatedToken {\n    bytes1 private constant ALLOWED = 0x11; // ERC-1066 \"Allowed\"\n\n    ICompliantService public immutable compliance;\n    bytes32 public immutable tokenId;\n    mapping(address =\u003e uint256) public balanceOf;\n\n    constructor(ICompliantService svc, bytes32 id) { compliance = svc; tokenId = id; }\n\n    function transfer(address to, uint256 value) external returns (bool) {\n        require(\n            compliance.checkTransferAllowed(tokenId, msg.sender, to, value) == ALLOWED,\n            \"transfer not allowed\"\n        );\n        compliance.updateTransferAccumulated(tokenId, msg.sender, to, value); // reverts on violation\n        balanceOf[msg.sender] -= value;\n        balanceOf[to] += value;\n        return true;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**(정체)입니다.\n- 명세는 예전 Solidity의 `byte` 타입을 사용합니다. 지금은 `bytes1`을 쓰세요. 또한 취소 이벤트의 이름이 `RevokedAccumulatedOperator`(인터페이스)와 `RevokedHoldOperator`(이벤트 목록)로 두 가지로 적혀 있습니다. 인터페이스의 이름이 일관된 쪽입니다.\n- 서비스에서 토큰을 추가·교체·제거하고 규칙을 바꿀 수 있는 주체는 그 서비스를 쓰는 모든 토큰을 사실상 통제합니다. 명세는 이 권한을 구현자에게 맡겨 둡니다.\n- 현지화된 오류 메시지는 ERC-1066 코드 위에 [ERC-1444](/eip-1444/)로 추가할 수 있습니다.\n- 이 표준은 메커니즘만 제공합니다. 특정 규칙 집합이 어떤 규제를 충족하는지는 법적인 문제이므로, 자격을 갖춘 전문가와 함께 검토하세요.\n"},"zh":{"lang":"zh","tldr":"一项已停滞的提案：定义一个共享的链上合规服务，受监管代币在每次转账、铸造或销毁前都会查询它，使 KYC/AML 类规则在同一笔交易中执行，而不是依赖链下审批步骤。","tags":["compliance","security-token","regulated","kyc","stagnant"],"related":[1462,1066,777,1444,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2009/","markdown":"## 它解决什么问题？\n\n受监管的代币（证券、电子货币等）必须执行 KYC 和反洗钱限额等法律规则。如果这些检查在链下进行，转账就变成两步：先申请，再等待运营方批准。这样既更慢，又重新引入了中心化的把关者。\n\n[ERC-1462](/eip-1462/) 已经提出了 `checkTransferAllowed` 之类的函数，但没有说明如何实现。ERC-2009 定义了一个 **Compliance Service**（合规服务）合约，它保存规则，并且可以被许多代币共享，例如同一司法辖区下的所有代币，因此检查可以在代币转账内部完全在链上运行。\n\n## 它如何运作\n\n参与方有：**代币**（调用该服务）、**代币持有者**（被检查的账户），以及一个可选的**操作员**，经授权可代表代币更新数据。\n\n1. **检查**（view）：`checkTransferAllowed`、`checkTransferFromAllowed`、`checkMintAllowed`、`checkBurnAllowed`。它们返回遵循 [ERC-1066](/eip-1066/) 的单字节状态码：`0x11` *Allowed*（允许）或 `0x10` *Disallowed*（不允许），或含义相同的发行方自定义代码。除非结果表示 *allowed*，否则代币必须 revert。\n2. **累计值更新**：`updateTransferAccumulated`、`updateMintAccumulated`、`updateBurnAccumulated` 与相应操作在同一笔交易中调用。它们记录累计数据（例如每个周期的交易量），并在会违反规则时 revert。规则本身由实现者自行决定。\n3. **代币注册表**：代币由 `bytes32 tokenId` 标识，而不是其地址。`addToken`、`replaceToken` 和 `removeToken` 管理这一映射，因此代币可以升级合约并保留其累计历史。\n4. **操作员**：`authorizeAccumulatedOperator`、`revokeAccumulatedOperator`、`isAccumulatedOperatorFor`，命名来自 [ERC-777](/eip-777/) 的操作员。\n\n更新时不会触发事件，因为代币自身的 `Transfer` 已经标记了这些操作。\n\n## 示例代码\n\n在 `transfer` 中查询该服务的代币（简化版）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface ICompliantService {\n    function checkTransferAllowed(bytes32 tokenId, address from, address to, uint256 value)\n        external view returns (bytes1);\n    function updateTransferAccumulated(bytes32 tokenId, address from, address to, uint256 value)\n        external;\n}\n\ncontract RegulatedToken {\n    bytes1 private constant ALLOWED = 0x11; // ERC-1066 \"Allowed\"\n\n    ICompliantService public immutable compliance;\n    bytes32 public immutable tokenId;\n    mapping(address =\u003e uint256) public balanceOf;\n\n    constructor(ICompliantService svc, bytes32 id) { compliance = svc; tokenId = id; }\n\n    function transfer(address to, uint256 value) external returns (bool) {\n        require(\n            compliance.checkTransferAllowed(tokenId, msg.sender, to, value) == ALLOWED,\n            \"transfer not allowed\"\n        );\n        compliance.updateTransferAccumulated(tokenId, msg.sender, to, value); // reverts on violation\n        balanceOf[msg.sender] -= value;\n        balanceOf[to] += value;\n        return true;\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**（停滞）。\n- 规范使用的是旧版 Solidity 的 `byte` 类型，现在请使用 `bytes1`。它还把撤销事件在接口中命名为 `RevokedAccumulatedOperator`，在事件列表中却命名为 `RevokedHoldOperator`；接口中的名称才是一致的那个。\n- 能在服务中添加、替换或移除代币并修改规则的人，实际上控制着所有使用该服务的代币。规范把这些权限留给实现者决定。\n- 可以在 ERC-1066 代码之上，用 [ERC-1444](/eip-1444/) 添加本地化的错误信息。\n- 该标准只提供机制。某套规则是否满足特定法规，属于法律问题，应与合格的法律顾问一起审查。\n"}},"requiredBy":[2020]}
