{"eip":6120,"title":"Universal Token Router","description":"A singleton router contract allows tokens to be spent in the transfer-and-call pattern instead of approve-then-call.","authors":["Derion (@derion-io)","Zergity (@Zergity)","Ngo Quang Anh (@anhnq82)","BerlinP (@BerlinP)","Khanh Pham (@blackskin18)","Hal Blackburn (@h4l)"],"status":"Review","type":"Standards Track","category":"ERC","created":"2022-12-12","requires":[20,165,721,1014,1155],"discussionsTo":"https://ethereum-magicians.org/t/eip-6120-universal-token-router/12142","repo":"ERCs","label":"ERC-6120","officialUrl":"https://eips.ethereum.org/EIPS/eip-6120","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6120.md","url":"https://eips.huatuo.xyz/eip-6120/","tldr":{"en":"A single shared router that users approve once, which then moves tokens only in transactions they sign themselves and checks the resulting balances, replacing per-app approve-then-call.","ja":"ユーザーが 1 回だけ承認する単一の共有ルーター。ルーターは、ユーザー自身が署名したトランザクションの中でのみトークンを移動し、結果の残高を確認する。アプリごとの approve してから呼び出す方式に代わるもの。","ko":"사용자가 한 번만 승인하는 단일 공유 라우터. 라우터는 사용자가 직접 서명한 트랜잭션 안에서만 토큰을 옮기고 결과 잔액을 확인하며, 앱마다 approve한 뒤 호출하는 방식을 대체한다.","zh":"一个用户只需授权一次的共享路由器，它仅在用户自己签名的交易中转移代币并检查最终余额，用以取代各应用各自的先 approve 再调用。"},"tags":["router","approvals","token","defi","security"],"explainers":{"en":{"lang":"en","tldr":"A single shared router that users approve once, which then moves tokens only in transactions they sign themselves and checks the resulting balances, replacing per-app approve-then-call.","tags":["router","approvals","token","defi","security"],"related":[20,721,1155,1014,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-6120/","markdown":"## What problem does it solve?\n\nSending ETH to a contract is one step: the value travels with the call. ERC-20 tokens cannot do that, so apps use **approve-then-call**: first you approve the app's contract, then it pulls your tokens. Each new app needs a new approval, approvals often point at upgradable or unaudited contracts, and leftover allowances have been the root of many exploits.\n\nThe Universal Token Router (UTR) separates the allowance from the application. You approve one router; the router only moves your tokens inside a transaction **you** sent to it, and can verify that you actually received what you expected.\n\n## How it works\n\nUsers call one function, `exec(outputs, actions)`:\n\n- **`outputs`** — balance checks. For each item (`recipient`, token standard, token, id, `amountOutMin`), the router records the balance at the start and end of `exec` and reverts with `INSUFFICIENT_OUTPUT_AMOUNT` if the gain is too small. The spec calls this *security-by-result*: what matters is that you ended up with the expected tokens.\n- **`actions`** — a list of `{inputs, code, data}`. For each action, the router first handles the `inputs`, then calls `code` with `data`.\n\nEach `Input` has a `mode`:\n\n| Mode | Meaning |\n| --- | --- |\n| `PAYMENT` (0) | Allow up to `amountIn` to be pulled from the sender to `recipient` during this transaction only, via `UTR.pay(...)` (for callback-style apps such as flash loans or Uniswap v3 pools) |\n| `TRANSFER` (1) | Transfer tokens from the sender to `recipient` right away |\n| `CALL_VALUE` (2) | Forward this much ETH as the call value |\n\nTokens are identified by `eip`: `0` for ETH, otherwise `20`, `721` or `1155`.\n\nTo stop the router from being tricked into calling `transferFrom` on a token, the target `code` must look like a non-token: either inherit the `NotToken` helper or report ERC-165 interface `0x61206120`. Pending payments are cleared before `exec` returns (the reference implementation uses transient storage), and leftover ETH is refunded.\n\nNew tokens can trust the UTR as an unlimited spender, so users never need an approval at all. The spec says the router is deployed at the same address on EVM chains via the [EIP-1014](/eip-1014/) singleton factory.\n\n## Sample code\n\nSwapping through a UTR-aware helper and requiring a minimum output (ethers v6):\n\n```ts\nimport { Contract, MaxUint256 } from \"ethers\";\n\nconst TRANSFER = 1n;\n\n// one-time approval for existing tokens\nawait tokenIn.approve(utrAddress, MaxUint256);\n\nawait utr.exec(\n  [{ recipient: me, eip: 20n, token: tokenOutAddr, id: 0n, amountOutMin: minOut }],\n  [{\n    inputs: [{ mode: TRANSFER, recipient: pairAddr, eip: 20n, token: tokenInAddr, id: 0n, amountIn }],\n    code: helperAddr,                       // must be a NotToken / 0x61206120 contract\n    data: helper.interface.encodeFunctionData(\"swapExactTokensForTokens\",\n            [amountIn, minOut, [tokenInAddr, tokenOutAddr], me, deadline]),\n  }],\n);\n```\n\nAn app contract that the router is allowed to call:\n\n```solidity\nabstract contract NotToken {\n    function allowance(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n    function isApprovedForAll(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n}\n\ncontract SwapHelper is NotToken { /* swap logic that sends output to `recipient` */ }\n```\n\n## Things to know\n\n- **Status: Review.** Not Final; interfaces may still change.\n- Token contracts must **never** report interface `0x61206120`; if they do, anyone can spend balances approved to the UTR.\n- Tokens sent to the router itself are lost. Send only as much ETH as the actions spend, as excess could be taken by a re-entrant action.\n- `discard` (used for sender authentication) cannot be verified by balances, so only rely on it with a router you trust.\n- Apps that credit `msg.sender` instead of an explicit `recipient` need an adapter to work with the UTR.\n- For signature-based approvals of a single token, compare [ERC-2612](/eip-2612/) `permit`; the UTR explicitly does not use permit signatures.\n"},"ja":{"lang":"ja","tldr":"ユーザーが 1 回だけ承認する単一の共有ルーター。ルーターは、ユーザー自身が署名したトランザクションの中でのみトークンを移動し、結果の残高を確認する。アプリごとの approve してから呼び出す方式に代わるもの。","tags":["router","approvals","token","defi","security"],"related":[20,721,1155,1014,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-6120/","markdown":"## 何を解決するのか\n\nETH をコントラクトに送るのは 1 ステップです。値は呼び出しと一緒に移動します。ERC-20 トークンにはそれができないため、アプリは **approve してから呼び出す**方式を使います。まずアプリのコントラクトを承認し、その後コントラクトがトークンを引き出します。新しいアプリごとに新しい承認が必要で、承認はアップグレード可能なコントラクトや未監査のコントラクトを指すことが多く、残った allowance は多くのエクスプロイトの原因になってきました。\n\nUniversal Token Router（UTR）は、allowance をアプリケーションから切り離します。承認するのは 1 つのルーターで、ルーターは**あなた**がそれに送ったトランザクションの中でのみあなたのトークンを移動し、期待したものを実際に受け取ったことを検証できます。\n\n## 仕組み\n\nユーザーは 1 つの関数 `exec(outputs, actions)` を呼びます。\n\n- **`outputs`** — 残高チェックです。各項目（`recipient`、トークン標準、トークン、id、`amountOutMin`）について、ルーターは `exec` の開始時と終了時の残高を記録し、増加分が小さすぎれば `INSUFFICIENT_OUTPUT_AMOUNT` で revert します。仕様はこれを *security-by-result* と呼んでいます。重要なのは、期待したトークンが最終的に手元にあることです。\n- **`actions`** — `{inputs, code, data}` のリストです。各アクションについて、ルーターはまず `inputs` を処理し、次に `data` を付けて `code` を呼び出します。\n\n各 `Input` には `mode` があります。\n\n| モード | 意味 |\n| --- | --- |\n| `PAYMENT` (0) | このトランザクションの間だけ、`UTR.pay(...)` を通じて送信者から `recipient` へ最大 `amountIn` まで引き出すことを許可（フラッシュローンや Uniswap v3 プールのようなコールバック型のアプリ向け） |\n| `TRANSFER` (1) | 送信者から `recipient` へ直ちにトークンを転送 |\n| `CALL_VALUE` (2) | この額の ETH を呼び出しの value として転送 |\n\nトークンは `eip` で識別されます。ETH は `0`、それ以外は `20`、`721`、`1155` です。\n\nルーターがだまされてトークンに対して `transferFrom` を呼ばされるのを防ぐため、対象の `code` はトークンではないように見えなければなりません。`NotToken` ヘルパーを継承するか、ERC-165 インターフェース `0x61206120` を報告します。保留中の支払いは `exec` が戻る前にクリアされ（リファレンス実装はトランジェントストレージを使用）、余った ETH は返金されます。\n\n新しいトークンは UTR を無制限の spender として信頼できるため、ユーザーは承認をまったく必要としなくなります。仕様によれば、ルーターは [EIP-1014](/eip-1014/) のシングルトンファクトリーを通じて、EVM チェーン上で同じアドレスにデプロイされます。\n\n## サンプルコード\n\nUTR 対応のヘルパーを通じてスワップし、最小出力を要求する（ethers v6）:\n\n```ts\nimport { Contract, MaxUint256 } from \"ethers\";\n\nconst TRANSFER = 1n;\n\n// one-time approval for existing tokens\nawait tokenIn.approve(utrAddress, MaxUint256);\n\nawait utr.exec(\n  [{ recipient: me, eip: 20n, token: tokenOutAddr, id: 0n, amountOutMin: minOut }],\n  [{\n    inputs: [{ mode: TRANSFER, recipient: pairAddr, eip: 20n, token: tokenInAddr, id: 0n, amountIn }],\n    code: helperAddr,                       // must be a NotToken / 0x61206120 contract\n    data: helper.interface.encodeFunctionData(\"swapExactTokensForTokens\",\n            [amountIn, minOut, [tokenInAddr, tokenOutAddr], me, deadline]),\n  }],\n);\n```\n\nルーターが呼び出すことを許可されるアプリのコントラクト:\n\n```solidity\nabstract contract NotToken {\n    function allowance(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n    function isApprovedForAll(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n}\n\ncontract SwapHelper is NotToken { /* swap logic that sends output to `recipient` */ }\n```\n\n## 知っておくべきこと\n\n- **ステータス: Review。** Final ではなく、インターフェースは今後変わる可能性があります。\n- トークンコントラクトはインターフェース `0x61206120` を**決して**報告してはなりません。報告すると、UTR に承認された残高を誰でも使えてしまいます。\n- ルーター自身に送られたトークンは失われます。アクションが使う分だけの ETH を送ってください。余剰分は再入するアクションに奪われる可能性があります。\n- `discard`（送信者の認証に使用）は残高では検証できないため、信頼できるルーターに対してのみ頼ってください。\n- 明示的な `recipient` ではなく `msg.sender` にクレジットするアプリは、UTR で動かすにはアダプターが必要です。\n- 単一トークンの署名ベースの承認については、[ERC-2612](/eip-2612/) の `permit` と比較してください。UTR は permit 署名を使わないことを明示しています。\n"},"ko":{"lang":"ko","tldr":"사용자가 한 번만 승인하는 단일 공유 라우터. 라우터는 사용자가 직접 서명한 트랜잭션 안에서만 토큰을 옮기고 결과 잔액을 확인하며, 앱마다 approve한 뒤 호출하는 방식을 대체한다.","tags":["router","approvals","token","defi","security"],"related":[20,721,1155,1014,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-6120/","markdown":"## 어떤 문제를 해결하나요?\n\n컨트랙트에 ETH를 보내는 것은 한 단계입니다. 값이 호출과 함께 이동합니다. ERC-20 토큰은 그렇게 할 수 없어서 앱은 **approve한 뒤 호출**하는 방식을 씁니다. 먼저 앱의 컨트랙트를 승인하고, 그다음 컨트랙트가 토큰을 가져갑니다. 새 앱마다 새 승인이 필요하고, 승인은 업그레이드 가능하거나 감사받지 않은 컨트랙트를 가리키는 경우가 많으며, 남아 있는 allowance는 많은 익스플로잇의 뿌리가 되어 왔습니다.\n\nUniversal Token Router(UTR)는 allowance를 애플리케이션에서 분리합니다. 여러분은 라우터 하나를 승인하고, 라우터는 **여러분**이 보낸 트랜잭션 안에서만 토큰을 옮기며, 기대한 것을 실제로 받았는지 검증할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n사용자는 함수 하나 `exec(outputs, actions)`를 호출합니다.\n\n- **`outputs`** — 잔액 검사입니다. 각 항목(`recipient`, 토큰 표준, 토큰, id, `amountOutMin`)에 대해 라우터는 `exec` 시작과 끝의 잔액을 기록하고, 증가분이 너무 작으면 `INSUFFICIENT_OUTPUT_AMOUNT`로 revert합니다. 사양은 이를 *security-by-result*라고 부릅니다. 중요한 것은 기대한 토큰을 실제로 갖게 되었는지입니다.\n- **`actions`** — `{inputs, code, data}`의 목록입니다. 각 액션에 대해 라우터는 먼저 `inputs`를 처리한 뒤 `data`로 `code`를 호출합니다.\n\n각 `Input`에는 `mode`가 있습니다.\n\n| 모드 | 의미 |\n| --- | --- |\n| `PAYMENT` (0) | 이 트랜잭션 동안만 `UTR.pay(...)`를 통해 전송자에서 `recipient`로 최대 `amountIn`까지 가져가도록 허용(플래시 론이나 Uniswap v3 풀 같은 콜백 방식 앱용) |\n| `TRANSFER` (1) | 전송자에서 `recipient`로 즉시 토큰 전송 |\n| `CALL_VALUE` (2) | 이만큼의 ETH를 호출 value로 전달 |\n\n토큰은 `eip`로 식별합니다. ETH는 `0`, 그 외에는 `20`, `721`, `1155`입니다.\n\n라우터가 속아서 토큰에 `transferFrom`을 호출하지 않도록, 대상 `code`는 토큰이 아닌 것처럼 보여야 합니다. `NotToken` 헬퍼를 상속하거나 ERC-165 인터페이스 `0x61206120`을 보고해야 합니다. 대기 중인 결제는 `exec`가 반환되기 전에 정리되며(레퍼런스 구현은 트랜지언트 스토리지 사용), 남은 ETH는 환불됩니다.\n\n새 토큰은 UTR을 무제한 spender로 신뢰할 수 있으므로 사용자는 승인이 아예 필요 없어집니다. 사양에 따르면 라우터는 [EIP-1014](/eip-1014/) 싱글턴 팩토리를 통해 EVM 체인에서 같은 주소에 배포됩니다.\n\n## 샘플 코드\n\nUTR을 아는 헬퍼를 통해 스왑하고 최소 출력을 요구하기(ethers v6):\n\n```ts\nimport { Contract, MaxUint256 } from \"ethers\";\n\nconst TRANSFER = 1n;\n\n// one-time approval for existing tokens\nawait tokenIn.approve(utrAddress, MaxUint256);\n\nawait utr.exec(\n  [{ recipient: me, eip: 20n, token: tokenOutAddr, id: 0n, amountOutMin: minOut }],\n  [{\n    inputs: [{ mode: TRANSFER, recipient: pairAddr, eip: 20n, token: tokenInAddr, id: 0n, amountIn }],\n    code: helperAddr,                       // must be a NotToken / 0x61206120 contract\n    data: helper.interface.encodeFunctionData(\"swapExactTokensForTokens\",\n            [amountIn, minOut, [tokenInAddr, tokenOutAddr], me, deadline]),\n  }],\n);\n```\n\n라우터가 호출할 수 있는 앱 컨트랙트:\n\n```solidity\nabstract contract NotToken {\n    function allowance(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n    function isApprovedForAll(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n}\n\ncontract SwapHelper is NotToken { /* swap logic that sends output to `recipient` */ }\n```\n\n## 알아둘 점\n\n- **상태: Review.** Final이 아니며 인터페이스는 아직 바뀔 수 있습니다.\n- 토큰 컨트랙트는 인터페이스 `0x61206120`을 **절대** 보고해서는 안 됩니다. 보고하면 누구나 UTR에 승인된 잔액을 쓸 수 있습니다.\n- 라우터 자신에게 보낸 토큰은 사라집니다. 액션이 쓰는 만큼만 ETH를 보내세요. 초과분은 재진입하는 액션이 가져갈 수 있습니다.\n- `discard`(전송자 인증에 사용)는 잔액으로 검증할 수 없으므로 신뢰하는 라우터에서만 의존하세요.\n- 명시적인 `recipient` 대신 `msg.sender`에게 크레딧하는 앱은 UTR과 함께 쓰려면 어댑터가 필요합니다.\n- 단일 토큰의 서명 기반 승인은 [ERC-2612](/eip-2612/) `permit`과 비교해 보세요. UTR은 permit 서명을 사용하지 않는다고 명시합니다.\n"},"zh":{"lang":"zh","tldr":"一个用户只需授权一次的共享路由器，它仅在用户自己签名的交易中转移代币并检查最终余额，用以取代各应用各自的先 approve 再调用。","tags":["router","approvals","token","defi","security"],"related":[20,721,1155,1014,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-6120/","markdown":"## 它解决什么问题？\n\n向合约发送 ETH 只需一步：价值随调用一起传递。ERC-20 代币做不到这一点，所以应用使用**先 approve 再调用**：先授权应用的合约，再由它提取你的代币。每个新应用都需要新的授权，授权往往指向可升级或未经审计的合约，而遗留的授权额度已成为许多攻击的根源。\n\nUniversal Token Router（UTR）把授权额度与应用分离。你只授权一个路由器；路由器只在**你**发给它的交易之内移动你的代币，并且可以验证你确实收到了预期的东西。\n\n## 它如何运作\n\n用户调用一个函数 `exec(outputs, actions)`：\n\n- **`outputs`** — 余额检查。对每一项（`recipient`、代币标准、代币、id、`amountOutMin`），路由器记录 `exec` 开始和结束时的余额，如果增加量过小，就以 `INSUFFICIENT_OUTPUT_AMOUNT` revert。规范称之为*结果即安全（security-by-result）*：重要的是你最终拿到了预期的代币。\n- **`actions`** — 一个 `{inputs, code, data}` 列表。对每个 action，路由器先处理 `inputs`，然后以 `data` 调用 `code`。\n\n每个 `Input` 都有一个 `mode`：\n\n| 模式 | 含义 |\n| --- | --- |\n| `PAYMENT` (0) | 仅在本次交易期间，允许通过 `UTR.pay(...)` 从发送者向 `recipient` 提取最多 `amountIn`（适用于闪电贷或 Uniswap v3 池这类回调式应用） |\n| `TRANSFER` (1) | 立即把代币从发送者转给 `recipient` |\n| `CALL_VALUE` (2) | 把这么多 ETH 作为调用的 value 转发 |\n\n代币通过 `eip` 标识：ETH 为 `0`，否则为 `20`、`721` 或 `1155`。\n\n为了防止路由器被诱骗对某个代币调用 `transferFrom`，目标 `code` 必须看起来不是代币：要么继承 `NotToken` 辅助合约，要么声明 ERC-165 接口 `0x61206120`。待处理的支付会在 `exec` 返回前清除（参考实现使用瞬态存储），多余的 ETH 会被退还。\n\n新代币可以把 UTR 当作无限额度的 spender 来信任，这样用户根本不需要任何授权。规范称，路由器通过 [EIP-1014](/eip-1014/) 的单例工厂，在各 EVM 链上部署在同一个地址。\n\n## 示例代码\n\n通过支持 UTR 的辅助合约进行兑换，并要求最小输出（ethers v6）：\n\n```ts\nimport { Contract, MaxUint256 } from \"ethers\";\n\nconst TRANSFER = 1n;\n\n// one-time approval for existing tokens\nawait tokenIn.approve(utrAddress, MaxUint256);\n\nawait utr.exec(\n  [{ recipient: me, eip: 20n, token: tokenOutAddr, id: 0n, amountOutMin: minOut }],\n  [{\n    inputs: [{ mode: TRANSFER, recipient: pairAddr, eip: 20n, token: tokenInAddr, id: 0n, amountIn }],\n    code: helperAddr,                       // must be a NotToken / 0x61206120 contract\n    data: helper.interface.encodeFunctionData(\"swapExactTokensForTokens\",\n            [amountIn, minOut, [tokenInAddr, tokenOutAddr], me, deadline]),\n  }],\n);\n```\n\n路由器被允许调用的应用合约：\n\n```solidity\nabstract contract NotToken {\n    function allowance(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n    function isApprovedForAll(address, address) external pure returns (string memory) { return \"THIS IS NOT A TOKEN\"; }\n}\n\ncontract SwapHelper is NotToken { /* swap logic that sends output to `recipient` */ }\n```\n\n## 需要注意\n\n- **状态：Review。** 不是 Final；接口仍可能变化。\n- 代币合约**绝不能**声明接口 `0x61206120`；否则任何人都可以花费已授权给 UTR 的余额。\n- 发送到路由器本身的代币会丢失。只发送 action 会用到的那么多 ETH，因为多余的部分可能被重入的 action 取走。\n- `discard`（用于发送者认证）无法通过余额来验证，因此只应在你信任的路由器上依赖它。\n- 把记账对象设为 `msg.sender` 而不是显式 `recipient` 的应用，需要适配器才能配合 UTR 使用。\n- 对于单个代币基于签名的授权，可对比 [ERC-2612](/eip-2612/) 的 `permit`；UTR 明确不使用 permit 签名。\n"}}}
