EIPs Explained

ERC-7144 · Review · ERC · 2023-05-07

ERC-7144: ERC-20 with transaction validation step.

An ERC-20 extension where transfer and approve do not execute immediately but create pending requests that a separate validator must confirm, so a stolen key alone cannot drain the wallet.

What problem does it solve?

With ERC-20, a single private key is enough to move all of a holder's tokens. Phishing and leaked keys therefore lead to instant, irreversible draining. Moving tokens to a cold wallet helps, but makes them inconvenient to use.

ERC-7144 adds a validation step: transfers and approvals initiated by the owner are only recorded as requests, and something else (for example a validator address connected to a dApp) must confirm them. A thief would need both the owner key and the validator's approval. It is the fungible counterpart of ERC-6997, which applies the same idea to ERC-721.

How it works

  • transfer / transferFrom called by the owner do not move tokens. They create a TransferValidation { from, to, amount, valid } and emit ValidateTransfer(from, to, amount, transferValidationId).
  • approve does not set an allowance. It creates an ApprovalValidation { owner, spender, amount, valid } and emits ValidateApproval(owner, spender, amount, approvalValidationId).
  • Validating a request sets valid = true (it can never be validated twice) and then performs the transfer or enables the approval.
  • A transferFrom by an already approved spender executes directly without validation, so DEXs and other protocols that pull tokens keep working once the approval itself was validated.

Read-only helpers:

Function Returns
isValidatorContract() true for a validator-enabled ERC-20
transferValidation(id) a pending or completed transfer request
approvalValidation(id) a pending or completed approval request
totalTransferValidations() / totalApprovalValidations() number of requests created

The standard deliberately does not define who validates or how; the validation function is internal. A project might use one validator address for everyone, or let each user pick their own.

Sample code

Watching for pending requests and checking their state (ethers v6):

import { Contract, JsonRpcProvider, formatUnits } from "ethers";

const abi = [
  "function isValidatorContract() view returns (bool)",
  "function transferValidation(uint256) view returns (tuple(address from,address to,uint256 amount,bool valid))",
  "event ValidateTransfer(address indexed from, address indexed to, uint256 amount, uint256 indexed transferValidationId)",
];

const provider = new JsonRpcProvider(process.env.RPC_URL);
const token = new Contract(process.env.TOKEN!, abi, provider);

if (!(await token.isValidatorContract())) throw new Error("not an ERC-7144 token");

token.on("ValidateTransfer", async (from, to, amount, id) => {
  const v = await token.transferValidation(id);
  console.log(`request #${id}: ${from} -> ${to} ${formatUnits(amount, 18)} valid=${v.valid}`);
  // a validator dApp would show this to the user and, if approved,
  // call the project's own (non-standard) validate function
});

Things to know

  • Status is Review; the interface may still change.
  • Every owner-initiated transfer becomes two steps, which adds latency and gas. Tools that expect transfer to move tokens immediately (and the Transfer event to follow) will be confused.
  • Security rests entirely on how validation is protected. If the validator key is weak or shared, the scheme adds little.
  • Approved spenders bypass validation, so a validated approval is still a powerful grant.
  • An alternative design with key wallets that pre-authorize transfers is ERC-6808.

#token #erc20 #security #anti-theft #validation

Details

Authors
Eduard López i Fina (@eduardfina)
Status
Review
Type
Standards Track / ERC
Created
2023-05-07
Requires

Machine-readable: Markdown · JSON