DAuth is a standard interface for accessing authorization delegation between smart contracts and users.
Abstract
The DAuth protocol defines a set of standard API allowing identity delegations between smart contracts without the user’s private key. Identity delegations include accessing and operating a user’s data and assets contained in the delegated contracts.
Motivation
The inspiration for designing DAuth comes from OAuth protocol that is extensively used in web applications. But unlike the centralized authorization of OAuth, DAuth works in a distributed manner, thus providing much more reliability and generality.
Specification
Resource owner: the authorizer
Resource contract: the contract providing data and operators
API: the resource contract APIs that the grantee contract can invoke
Client contract: the grantee contract using authorization to access and operate the data
Grantee request: the client contract calls the resource contract with the authorizer authorization
AuthInfo
structAuthInfo{string[]funcNames;uintexpireAt;}
Required - The struct contains user authorization information
funcNames: a list of function names callable by the granted contract
expireAt: the authorization expire timestamp in seconds
This event MUST trigger when the authorizer grant a new authorization when grant or regrant processes successfully
Revoke
eventRevoke(address_authorizer,address_grantee);
This event MUST trigger when the authorizer revoke a specific authorization successfully
Callable Resource Contract Functions
All public or external functions that are allowed the grantee to call MUST use overload to implement two functions: The First one is the standard method that the user invokes directly, the second one is the grantee methods of the same function name with one more authorizer address parameter.
The current design of many smart contracts only considers the user invokes the smart contract functions by themselves using the private key. However, in some case, the user wants to delegate other client smart contracts to access and operate their data or assets in the resource smart contract. There isn’t a common protocol to provide a standard delegation approach.
Rationale
On the Ethereum platform, all storage is transparent and the msg.sender is reliable. Therefore, the DAuth don’t need an access_token like OAuth. DAuth just recodes the users’ authorization for the specific client smart contract’s address. It is simple and reliable on the Ethereum platform.
Backwards Compatibility
This EIP introduces no backward compatibility issues. In the future, the new version protocol has to keep these interfaces.
Implementation
Following is the DAuth Interface implementation. Furthermore, the example implementations of EIP20 Interface and ERC-DAuth Interface are also provided. Developers can easily implement their own contracts with ERC-DAuth Interface and other EIP.
ERC-DAuth Interface implementation is available at: