{"eip":1207,"title":"DAuth Access Delegation Standard","description":"DAuth is a standard interface for accessing authorization delegation between smart contracts and users.","authors":["Xiaoyu Wang (@wxygeek)","Bicong Wang (@Wangbicong)"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2018-07-10","discussionsTo":"https://github.com/ethereum/EIPs/issues/1207","repo":"ERCs","label":"ERC-1207","officialUrl":"https://eips.ethereum.org/EIPS/eip-1207","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1207.md","url":"https://eips.huatuo.xyz/eip-1207/","tldr":{"en":"An OAuth-style pattern for contracts: a user grants another contract time-limited permission to call named functions on their behalf, without sharing a private key.","ja":"コントラクト向けの OAuth 風パターン。ユーザーが、秘密鍵を共有することなく、別のコントラクトに自分の代わりに指定の関数を呼び出す期限付きの権限を与える。","ko":"컨트랙트를 위한 OAuth 스타일 패턴. 사용자가 개인키를 공유하지 않고도 다른 컨트랙트에 자신을 대신해 지정한 함수를 호출할 수 있는 기한 있는 권한을 부여한다.","zh":"面向合约的 OAuth 式模式：用户授予另一个合约有时限的权限，使其代表自己调用指定的函数，而无需共享私钥。"},"tags":["authorization","delegation","access-control","interface"],"explainers":{"en":{"lang":"en","tldr":"An OAuth-style pattern for contracts: a user grants another contract time-limited permission to call named functions on their behalf, without sharing a private key.","tags":["authorization","delegation","access-control","interface"],"related":[20,2612,2771],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1207/","markdown":"## What problem does it solve?\n\nMost contracts assume the user calls every function themselves with their own key, so `msg.sender` is always the owner. Sometimes a user wants another contract (a \"client\" app) to act on their data or assets in a \"resource\" contract, for example to approve tokens on their behalf. There was no common way to express that delegation.\n\nDAuth borrows the idea of OAuth from the web: the user grants a specific contract access to a specific set of functions until an expiry time. Because Ethereum storage is public and `msg.sender` is reliable, no access token is needed; the resource contract just records who granted what to whom.\n\n## How it works\n\nThe resource contract stores, per (user, client contract) pair, an `AuthInfo`:\n\n```solidity\nstruct AuthInfo {\n    string[] funcNames; // functions the client may call\n    uint expireAt;      // unix timestamp\n}\nmapping(address =\u003e mapping(address =\u003e AuthInfo)) userAuth;\n```\n\nInterface:\n\n| Function / event | Purpose |\n| --- | --- |\n| `grant(grantee, invokes, expireAt)` | User authorises a client; `invokes` is a space-separated list of function names. Emits `Grant` |\n| `regrant(...)` | Optional: change an existing grant |\n| `revoke(grantee)` | Remove a grant. Emits `Revoke` |\n| `verify(authorizer, invoke)` | Internal check that the caller is allowed to call `invoke` for `authorizer` |\n| `callableFuncNames` / `updateCallableFuncNames` | Which functions the resource contract exposes to delegates at all |\n\nEvery delegatable function is **overloaded**: the normal version acts for `msg.sender`, and a second version takes an extra `authorizer` address, calls `verify`, and acts for that user.\n\n## Sample code\n\nThe pattern from the spec, applied to an ERC-20 style `approve`:\n\n```solidity\nfunction approve(address spender, uint256 value) public returns (bool) {\n    return _approve(msg.sender, spender, value);\n}\n\n// Called by a client contract that the user has granted \"approve\" to\nfunction approve(address spender, uint256 value, address authorizer) public returns (bool) {\n    verify(authorizer, \"approve\");\n    return _approve(authorizer, spender, value);\n}\n\nfunction _approve(address owner, address spender, uint256 value) internal returns (bool) {\n    allowed[owner][spender] = value;\n    emit Approval(owner, spender, value);\n    return true;\n}\n```\n\nThe user grants access once:\n\n```solidity\nresource.grant(clientContract, \"approve transfer\", block.timestamp + 7 days);\n```\n\n## Things to know\n\n- Status is **Stagnant**. It did not become a widely used standard.\n- Permissions are stored and compared as strings, which is gas-heavy; a modern design would more likely use function selectors (`bytes4`).\n- A grant is broad: the client can call the named function with any arguments until expiry or revocation. Keep expiries short and grant only what is needed.\n- Today the common approaches to \"someone else acts for me\" are signed approvals such as [ERC-2612](/eip-2612/) `permit` and meta-transactions such as [ERC-2771](/eip-2771/), rather than per-contract grant tables.\n"},"ja":{"lang":"ja","tldr":"コントラクト向けの OAuth 風パターン。ユーザーが、秘密鍵を共有することなく、別のコントラクトに自分の代わりに指定の関数を呼び出す期限付きの権限を与える。","tags":["authorization","delegation","access-control","interface"],"related":[20,2612,2771],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1207/","markdown":"## 何を解決するのか\n\nほとんどのコントラクトは、ユーザーが自分の鍵ですべての関数を自分で呼び出すことを前提としており、`msg.sender` は常に所有者です。しかしユーザーが、別のコントラクト（「クライアント」アプリ）に、「リソース」コントラクト内の自分のデータや資産を操作させたいことがあります。たとえば自分の代わりにトークンを approve する場合です。この委任を表現する共通の方法はありませんでした。\n\nDAuth はウェブの OAuth の考え方を借ります。ユーザーは特定のコントラクトに、特定の関数の集合へのアクセスを有効期限まで許可します。Ethereum のストレージは公開されており `msg.sender` は信頼できるため、アクセストークンは不要です。リソースコントラクトは、誰が誰に何を許可したかを記録するだけです。\n\n## 仕組み\n\nリソースコントラクトは、（ユーザー, クライアントコントラクト）の組ごとに `AuthInfo` を保存します。\n\n```solidity\nstruct AuthInfo {\n    string[] funcNames; // functions the client may call\n    uint expireAt;      // unix timestamp\n}\nmapping(address =\u003e mapping(address =\u003e AuthInfo)) userAuth;\n```\n\nインターフェース:\n\n| 関数 / イベント | 役割 |\n| --- | --- |\n| `grant(grantee, invokes, expireAt)` | ユーザーがクライアントを認可する。`invokes` は関数名をスペースで区切ったリスト。`Grant` を emit する |\n| `regrant(...)` | 任意: 既存の許可を変更する |\n| `revoke(grantee)` | 許可を取り消す。`Revoke` を emit する |\n| `verify(authorizer, invoke)` | 呼び出し元が `authorizer` のために `invoke` を呼べるかを確認する内部チェック |\n| `callableFuncNames` / `updateCallableFuncNames` | リソースコントラクトが委任先に公開する関数の一覧 |\n\n委任可能なすべての関数は**オーバーロード**されます。通常のバージョンは `msg.sender` のために動作し、2 つ目のバージョンは追加の `authorizer` アドレスを受け取り、`verify` を呼んでそのユーザーのために動作します。\n\n## サンプルコード\n\n仕様のパターンを、ERC-20 風の `approve` に適用した例:\n\n```solidity\nfunction approve(address spender, uint256 value) public returns (bool) {\n    return _approve(msg.sender, spender, value);\n}\n\n// Called by a client contract that the user has granted \"approve\" to\nfunction approve(address spender, uint256 value, address authorizer) public returns (bool) {\n    verify(authorizer, \"approve\");\n    return _approve(authorizer, spender, value);\n}\n\nfunction _approve(address owner, address spender, uint256 value) internal returns (bool) {\n    allowed[owner][spender] = value;\n    emit Approval(owner, spender, value);\n    return true;\n}\n```\n\nユーザーは一度だけアクセスを許可します。\n\n```solidity\nresource.grant(clientContract, \"approve transfer\", block.timestamp + 7 days);\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。広く使われる標準にはなりませんでした。\n- 権限は文字列として保存・比較されるためガスコストが高く、現代的な設計なら関数セレクター（`bytes4`）を使う可能性が高いでしょう。\n- 許可の範囲は広いものです。クライアントは、有効期限が切れるか取り消されるまで、指定された関数を任意の引数で呼び出せます。有効期限は短くし、必要なものだけを許可してください。\n- 今日「他の誰かが自分の代わりに動く」ための一般的な方法は、コントラクトごとの許可テーブルではなく、[ERC-2612](/eip-2612/) の `permit` のような署名付き承認や、[ERC-2771](/eip-2771/) のようなメタトランザクションです。\n"},"ko":{"lang":"ko","tldr":"컨트랙트를 위한 OAuth 스타일 패턴. 사용자가 개인키를 공유하지 않고도 다른 컨트랙트에 자신을 대신해 지정한 함수를 호출할 수 있는 기한 있는 권한을 부여한다.","tags":["authorization","delegation","access-control","interface"],"related":[20,2612,2771],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1207/","markdown":"## 어떤 문제를 해결하나요?\n\n대부분의 컨트랙트는 사용자가 자신의 키로 모든 함수를 직접 호출한다고 가정하므로 `msg.sender`는 항상 소유자입니다. 하지만 사용자가 다른 컨트랙트(\"클라이언트\" 앱)가 \"리소스\" 컨트랙트에 있는 자신의 데이터나 자산을 다루게 하고 싶을 때가 있습니다. 예를 들어 자신을 대신해 토큰을 승인하는 경우입니다. 이런 위임을 표현하는 공통된 방법은 없었습니다.\n\nDAuth는 웹의 OAuth 아이디어를 빌려옵니다. 사용자는 특정 컨트랙트에 특정 함수 집합에 대한 접근을 만료 시각까지 허용합니다. 이더리움 스토리지는 공개되어 있고 `msg.sender`는 신뢰할 수 있으므로 액세스 토큰이 필요 없습니다. 리소스 컨트랙트는 누가 누구에게 무엇을 허용했는지만 기록합니다.\n\n## 어떻게 동작하나요?\n\n리소스 컨트랙트는 (사용자, 클라이언트 컨트랙트) 쌍마다 `AuthInfo`를 저장합니다.\n\n```solidity\nstruct AuthInfo {\n    string[] funcNames; // functions the client may call\n    uint expireAt;      // unix timestamp\n}\nmapping(address =\u003e mapping(address =\u003e AuthInfo)) userAuth;\n```\n\n인터페이스:\n\n| 함수 / 이벤트 | 역할 |\n| --- | --- |\n| `grant(grantee, invokes, expireAt)` | 사용자가 클라이언트를 승인. `invokes`는 공백으로 구분한 함수 이름 목록. `Grant`를 emit |\n| `regrant(...)` | 선택: 기존 권한을 변경 |\n| `revoke(grantee)` | 권한을 제거. `Revoke`를 emit |\n| `verify(authorizer, invoke)` | 호출자가 `authorizer`를 위해 `invoke`를 호출할 수 있는지 확인하는 내부 검사 |\n| `callableFuncNames` / `updateCallableFuncNames` | 리소스 컨트랙트가 위임받은 쪽에 노출하는 함수가 무엇인지 |\n\n위임 가능한 모든 함수는 **오버로드**됩니다. 일반 버전은 `msg.sender`를 위해 동작하고, 두 번째 버전은 `authorizer` 주소를 추가로 받아 `verify`를 호출하고 그 사용자를 위해 동작합니다.\n\n## 샘플 코드\n\n명세의 패턴을 ERC-20 스타일 `approve`에 적용한 예:\n\n```solidity\nfunction approve(address spender, uint256 value) public returns (bool) {\n    return _approve(msg.sender, spender, value);\n}\n\n// Called by a client contract that the user has granted \"approve\" to\nfunction approve(address spender, uint256 value, address authorizer) public returns (bool) {\n    verify(authorizer, \"approve\");\n    return _approve(authorizer, spender, value);\n}\n\nfunction _approve(address owner, address spender, uint256 value) internal returns (bool) {\n    allowed[owner][spender] = value;\n    emit Approval(owner, spender, value);\n    return true;\n}\n```\n\n사용자는 한 번만 접근을 허용합니다.\n\n```solidity\nresource.grant(clientContract, \"approve transfer\", block.timestamp + 7 days);\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 널리 쓰이는 표준이 되지 못했습니다.\n- 권한은 문자열로 저장되고 비교되므로 가스 비용이 큽니다. 현대적인 설계라면 함수 셀렉터(`bytes4`)를 쓰는 편이 더 가능성이 높습니다.\n- 권한 범위가 넓습니다. 클라이언트는 만료되거나 취소될 때까지 지정된 함수를 어떤 인자로든 호출할 수 있습니다. 만료 기간은 짧게 하고 필요한 것만 허용하세요.\n- 오늘날 \"다른 누군가가 나를 대신해 행동\"하게 하는 일반적인 방법은 컨트랙트별 권한 테이블이 아니라 [ERC-2612](/eip-2612/) `permit` 같은 서명 승인이나 [ERC-2771](/eip-2771/) 같은 메타 트랜잭션입니다.\n"},"zh":{"lang":"zh","tldr":"面向合约的 OAuth 式模式：用户授予另一个合约有时限的权限，使其代表自己调用指定的函数，而无需共享私钥。","tags":["authorization","delegation","access-control","interface"],"related":[20,2612,2771],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1207/","markdown":"## 它解决什么问题？\n\n大多数合约假定用户用自己的密钥亲自调用每个函数，所以 `msg.sender` 始终是所有者。但有时用户希望另一个合约（\"客户端\"应用）去操作自己在\"资源\"合约中的数据或资产，例如代表自己授权代币。此前没有一种通用的方式来表达这种委托。\n\nDAuth 借用了 Web 上 OAuth 的思路：用户授予某个特定合约访问一组特定函数的权限，直到过期时间。由于以太坊的存储是公开的，而且 `msg.sender` 可靠，所以不需要访问令牌；资源合约只需记录谁把什么授予了谁。\n\n## 它如何运作\n\n资源合约针对每一对（用户，客户端合约）存储一个 `AuthInfo`：\n\n```solidity\nstruct AuthInfo {\n    string[] funcNames; // functions the client may call\n    uint expireAt;      // unix timestamp\n}\nmapping(address =\u003e mapping(address =\u003e AuthInfo)) userAuth;\n```\n\n接口：\n\n| 函数 / 事件 | 用途 |\n| --- | --- |\n| `grant(grantee, invokes, expireAt)` | 用户授权一个客户端；`invokes` 是以空格分隔的函数名列表。触发 `Grant` |\n| `regrant(...)` | 可选：修改已有的授权 |\n| `revoke(grantee)` | 撤销授权。触发 `Revoke` |\n| `verify(authorizer, invoke)` | 内部检查，确认调用者被允许为 `authorizer` 调用 `invoke` |\n| `callableFuncNames` / `updateCallableFuncNames` | 资源合约究竟向被委托方开放哪些函数 |\n\n每个可被委托的函数都会被**重载**：普通版本为 `msg.sender` 执行，第二个版本多接收一个 `authorizer` 地址，调用 `verify`，并为该用户执行。\n\n## 示例代码\n\n规范中的模式，应用到 ERC-20 风格的 `approve` 上：\n\n```solidity\nfunction approve(address spender, uint256 value) public returns (bool) {\n    return _approve(msg.sender, spender, value);\n}\n\n// Called by a client contract that the user has granted \"approve\" to\nfunction approve(address spender, uint256 value, address authorizer) public returns (bool) {\n    verify(authorizer, \"approve\");\n    return _approve(authorizer, spender, value);\n}\n\nfunction _approve(address owner, address spender, uint256 value) internal returns (bool) {\n    allowed[owner][spender] = value;\n    emit Approval(owner, spender, value);\n    return true;\n}\n```\n\n用户只需授权一次：\n\n```solidity\nresource.grant(clientContract, \"approve transfer\", block.timestamp + 7 days);\n```\n\n## 需要注意\n\n- 状态是 **Stagnant**。它没有成为被广泛使用的标准。\n- 权限以字符串形式存储和比较，gas 开销很大；现代设计更可能使用函数选择器（`bytes4`）。\n- 授权范围很宽：在过期或被撤销之前，客户端可以用任意参数调用指定的函数。请把有效期设得短一些，只授予所需的权限。\n- 如今解决\"别人代我操作\"的常见做法是 [ERC-2612](/eip-2612/) 的 `permit` 这类签名授权，以及 [ERC-2771](/eip-2771/) 这类元交易，而不是每个合约各自的授权表。\n"}}}
