EIPs Explained

ERC-2018 · Stagnant · ERC · 2019-04-30

ERC-2018: Clearable Token

A token extension for regulated assets where transfers are first ordered and held, then executed or rejected by a clearing agent after checks such as KYC/AML that may happen off-chain.

What problem does it solve?

A regulated token (for example tokenised money or securities) must often check every transfer against rules such as KYC or anti-money-laundering requirements. Some of those checks cannot be done on-chain, so a transfer cannot simply succeed or fail in one call.

ERC-2018 borrows the banking idea of clearing: the time between committing to a payment and actually settling it. A user orders a transfer, the funds are reserved, and a clearing agent reviews it and then executes or rejects it. Because the amount is held, the payer cannot spend it elsewhere in the meantime, so an approved transfer is guaranteed to go through.

How it works

It builds on the hold mechanism of ERC-1996. Roles:

  • Orderer: the account owner, or an approved operator, who orders the transfer.
  • Clearing agent: the account that processes, executes or rejects it.

Each transfer is identified by a string operationId (unique; ordering with a reused id must revert) and moves through these statuses:

Ordered → (optional) InProcess → Executed or Rejected, or Cancelled by the orderer.

Function Who Effect
orderTransfer / orderTransferFrom orderer Creates the order and holds the amount
cancelTransfer orderer Cancels, but not once InProcess
processClearableTransfer clearing agent Marks InProcess, locking out cancellation
executeClearableTransfer clearing agent Moves the held tokens to the payee
rejectClearableTransfer clearing agent Releases the hold, with a reason
retrieveClearableTransferData anyone Returns from, to, value and status

Operators are managed with authorizeClearableTransferOperator, revokeClearableTransferOperator and isClearableTransferOperatorFor, named after ERC-777's operator functions. Every step emits an event. Whether plain ERC-20 transfer/transferFrom still work is left to the implementer.

Sample code

Ordering a transfer and following it with ethers v6:

import { Contract, Wallet, JsonRpcProvider, parseUnits } from "ethers";

const abi = [
  "function orderTransfer(string operationId, address to, uint256 value) returns (bool)",
  "function retrieveClearableTransferData(string operationId) view returns (address from, address to, uint256 value, uint8 status)",
  "event ClearableTransferExecuted(address indexed orderer, string operationId)",
  "event ClearableTransferRejected(address indexed orderer, string operationId, string reason)",
];
const provider = new JsonRpcProvider(process.env.RPC_URL);
const user = new Wallet(process.env.PRIVATE_KEY!, provider);
const token = new Contract(process.env.TOKEN!, abi, user);

const opId = `acme-${Date.now()}`; // a unique prefix avoids collisions
await (await token.orderTransfer(opId, payee, parseUnits("100", 18))).wait();

const STATUS = ["Nonexistent", "Ordered", "InProcess", "Executed", "Rejected", "Cancelled"];
const [, , , status] = await token.retrieveClearableTransferData(opId);
console.log(STATUS[Number(status)]); // "Ordered" until the clearing agent acts

Things to know

  • Status: Stagnant, as is the ERC-1996 hold standard it depends on.
  • How the clearing agent is chosen and what it checks are outside the standard.
  • operationId is a shared namespace; the spec recommends a unique prefix per issuer.
  • Without the optional InProcess step, the orderer can cancel at any time, even while the agent is reviewing.

#token #regulated #compliance #clearing #hold

Details

Authors
Julio Faura <[email protected]>, Fernando Paris <[email protected]>, Daniel Lehrner <[email protected]>
Status
Stagnant
Type
Standards Track / ERC
Created
2019-04-30
Requires
Required by

Machine-readable: Markdown · JSON