EIPs Explained

ERC-2009 · Stagnant · ERC · 2019-05-09

ERC-2009: Compliance Service

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.

What problem does it solve?

Regulated 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.

ERC-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.

How it works

Actors: 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.

  1. Checks (view): checkTransferAllowed, checkTransferFromAllowed, checkMintAllowed, checkBurnAllowed. They return a one-byte status code following ERC-1066: 0x11 Allowed or 0x10 Disallowed, or an issuer-specific code with the same meaning. The token must revert unless the result means allowed.
  2. 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.
  3. 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.
  4. Operators: authorizeAccumulatedOperator, revokeAccumulatedOperator, isAccumulatedOperatorFor, named after ERC-777 operators.

No event is emitted on updates, since the token's own Transfer already marks them.

Sample code

A token consulting the service inside transfer (simplified):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ICompliantService {
    function checkTransferAllowed(bytes32 tokenId, address from, address to, uint256 value)
        external view returns (bytes1);
    function updateTransferAccumulated(bytes32 tokenId, address from, address to, uint256 value)
        external;
}

contract RegulatedToken {
    bytes1 private constant ALLOWED = 0x11; // ERC-1066 "Allowed"

    ICompliantService public immutable compliance;
    bytes32 public immutable tokenId;
    mapping(address => uint256) public balanceOf;

    constructor(ICompliantService svc, bytes32 id) { compliance = svc; tokenId = id; }

    function transfer(address to, uint256 value) external returns (bool) {
        require(
            compliance.checkTransferAllowed(tokenId, msg.sender, to, value) == ALLOWED,
            "transfer not allowed"
        );
        compliance.updateTransferAccumulated(tokenId, msg.sender, to, value); // reverts on violation
        balanceOf[msg.sender] -= value;
        balanceOf[to] += value;
        return true;
    }
}

Things to know

  • Status is Stagnant.
  • 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.
  • 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.
  • Localised error messages can be added with ERC-1444 on top of ERC-1066 codes.
  • The standard provides mechanics only. Whether a given rule set satisfies any particular regulation is a legal question to review with qualified counsel.

#compliance #security-token #regulated #kyc #stagnant

Details

Authors
Daniel Lehrner <[email protected]>
Status
Stagnant
Type
Standards Track / ERC
Created
2019-05-09
Requires
Required by

Machine-readable: Markdown · JSON