ERC-1207 DAuth Permission Delegation Standard (DAuth Access Delegation Standard)

Stagnant · Accounts & wallets · created 2018-07-10

A standard that lets a smart contract delegate access to its own assets or data to another contract within a defined scope and time period, without handing over its private key.

Why it is needed

Existing smart contracts only assume a situation where a user signs directly with their own private key to call a function. If you want a repeated task like a token transfer or approval to be handled by another contract, such as an automation service, on the user's behalf, the only options were to obtain a signature every time or to hand over the private key, both of which carried heavy security risks and were cumbersome. On the web, OAuth solves this kind of delegation problem through a centralized server, but Ethereum has no common specification for delegating permissions between contracts, so every project had to build its own ad hoc workaround. DAuth fills this gap by providing a standard interface that lets a contract delegate only specific functions to another contract for a specific period, without a private key, and revoke that delegation at any time.

What to implement

In depth

The AuthInfo struct and permission scope

AuthInfo consists of funcNames (the list of function names the delegated contract is allowed to call) and expireAt (an expiration timestamp in seconds). A single delegation is scoped so that it is valid only for specific functions and only until a specific point in time.

The userAuth mapping structure

userAuth has the form mapping(address => mapping(address => AuthInfo)), mapping a (grantor address, grantee contract address) pair to the corresponding AuthInfo object. This lets a single user grant different scopes of permission to multiple contracts independently.

The roles of callableFuncNames and verify

callableFuncNames is the full list of methods that other contracts are allowed to call. Per the specification, every callable function included in this list must verify the caller's permission. The internal verify function takes the authorizer's address and the name of the method being invoked (_invoke) to check permission, and must either return success or throw; no other outcome is allowed.

grant·regrant·revoke

grant (required) takes the _grantee address, a space-separated string of callable method names (_invokes), and an expiration time (_expireAt) to create a delegation, and must emit a Grant event on success. regrant (optional) changes an existing delegation using the same arguments. revoke (required) takes only the _grantee address and deletes that delegation, and must emit a Revoke event on success. For grant, verify, and revoke, no outcome other than returning success or throwing is allowed.

Callable functions implemented via an overload pattern

Every public/external function intended to support delegation must be implemented together as two overloaded versions. One is the standard method called directly by the user, and the other is a grantee-facing method with the same name plus an added authorizer address parameter. In the specification's approve example, the grantee-facing approve(_spender, _value, _authorizer) checks permission via verify(_authorizer, "approve") and then executes the internal _approve logic treating the authorizer as the caller.

Design rationale that differs from OAuth

According to the Rationale, because on Ethereum all storage is transparently public and msg.sender can be trusted, DAuth does not need to issue a separate access_token the way OAuth does. Instead, it only needs to record the fact of a user's grant as an (authorizer, grantee) pair, which the document explains makes the structure simpler and more trustworthy.

Proposal status

This ERC is in Stagnant status. It is a proposal that is no longer being actively discussed and has stalled, so it may be changed or may never be adopted.

Original ERC · ← ERCs