ERC-7715 Wallet execution permission requests (Request Permissions from Wallets)

Draft · Accounts & wallets · created 2024-05-24

Defines a JSON-RPC method that lets a dApp request permissions from a wallet in advance and execute transactions on the user's behalf within the scope the user approved.

Why it is needed

Right now, most dApps (decentralized apps) require the user to open their wallet and sign a transaction one by one every time they do something. In apps with frequent interactions, such as games, approving every single action is cumbersome and keeps breaking the flow. There is a bigger problem too: if the user does not keep their wallet connected, the dApp has no way to send transactions at all. This makes it impossible to build features that need to execute while the user is away, such as recurring subscriptions, passive investing, or limit orders. This standard solves this problem by defining a JSON-RPC method that lets a dApp request scoped permissions from a wallet, so that once the user approves them once, the dApp can execute transactions on the user's behalf within that scope.

What to implement

In depth

Common structure of permissions and rules

This standard does not define a complete list of permission and rule types. Any type can be used as long as both the dApp and the wallet support it, and new types should be defined in a separate ERC while following the BasePermission or BaseRule structure. BasePermission has the fields type, isAdjustmentAllowed, and data. isAdjustmentAllowed is a boolean specified by the dApp indicating whether the wallet is allowed to narrow or widen the scope of the permission to match the user's approval conditions. BaseRule has the fields type and data; as an example, the defined expiry rule invalidates the permission after the Unix timestamp written in data.timestamp. Type names must not overlap, because if two different permissions or two different rules share the same type name, what the dApp requested and what the wallet granted could end up mismatched.

wallet_requestExecutionPermissions request

The request params is an array of PermissionRequest objects. chainId specifies, per EIP-155, the chain this request applies to. from is the user account that will grant the permission; if omitted, the user can choose the account. to is the dApp session account associated with the permission. permission defines what the to account is allowed to do on behalf of the from account, and rules define the restrictions the to account must observe when using that permission. The original example requests a permission of type native-token-allowance with an expiry rule attached.

Response fields: context, dependencies, delegationManager

The response contains all fields from the original request, but there is no guarantee the values match the request, since the wallet may have adjusted them. context is a value that identifies the permission when revoking or using it, and is a field required by ERC-7710. dependencies is an array of factory and factoryData pairs as defined in ERC-4337, indicating accounts that must be deployed before the permission can be used. Within a single entry, both fields must be present together or absent together, and if all related accounts are already deployed, the wallet must return an empty array. The dApp must deploy each account by calling the factory with factoryData. delegationManager is also a field required by ERC-7710. If the request is invalid or the wallet cannot grant the permission, it must return an error using a code defined in ERC-1193.

Methods for querying and revoking permissions

wallet_getSupportedExecutionPermissions returns an object keyed by the permission types the wallet supports, and it is recommended that each type include a list of supported chains (chainIds) and a list of applicable rule types (ruleTypes). wallet_getGrantedExecutionPermissions must return all granted permissions that have not yet been revoked. wallet_revokeExecutionPermission takes a permissionContext and revokes the permission, returning an empty response on success.

Using a permission: calling redeemDelegation

The permission response is used by the account in the to field via the ERC-7710 interface. The permission holder, whether an externally owned account (EOA) or a contract, of any account type, can construct the transaction or UserOp using whatever payment or relay infrastructure it wants. It sends a message to the delegationManager from the response and calls the redeemDelegation function, passing the response's context into _permissionContexts and the content for the user's account to execute into _executionCallData. The execution content is defined as an Execution struct consisting of target (address), value (uint256), and callData (bytes). The original example code encodes target, value, and callData, chooses an execution mode (SingleDefault), and sends the transaction to the delegationManager.

Design rationale: the opaque permissionsContext

This ERC only defines the interaction between the dApp and the wallet, not how the wallet enforces the permission. This means the wallet needs a flexible way to pass information to the dApp, so permissionsContext is designed as an opaque string that can hold arbitrary information from different permission schemes. Mandating UUIDs for permission and rule types was also considered, but the simpler approach of requiring new types to be defined as an ERC was chosen instead. Wallets that do not support this method are recommended to return an error message when it is called.

A Proposal in Draft Stage

This ERC has been in Draft status since May 2024. Its content may still change, so the latest original text should be checked before implementing. This standard assumes ERC-4337 and ERC-7710.

Things to watch out for

Original ERC · ← ERCs