---
eip: 7715
label: ERC-7715
title: Request Permissions from Wallets
status: Draft
type: Standards Track
category: ERC
created: 2024-05-24
requires: 4337, 7710
official: https://eips.ethereum.org/EIPS/eip-7715
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7715.md
canonical: https://eips.huatuo.xyz/zh/eip-7715/
lang: zh
tldr: 新增 wallet_requestExecutionPermissions JSON-RPC 方法，让 dapp 可以向钱包请求有范围限制、会过期的权限，以便代表用户操作，而无需每笔交易都弹窗确认。
tags: [wallet, permissions, json-rpc, account-abstraction, delegation]
---

# ERC-7715: Request Permissions from Wallets

> Adds JSON-RPC method for requesting permissions from a wallet

**TL;DR:** 新增 wallet_requestExecutionPermissions JSON-RPC 方法，让 dapp 可以向钱包请求有范围限制、会过期的权限，以便代表用户操作，而无需每笔交易都弹窗确认。

## 它解决什么问题？

在常规的 dapp 流程中，每一次链上操作都需要用户打开钱包签名。这在游戏等交互式应用中很烦琐，也让一些产品无法实现：订阅、定期买入或限价单都需要在用户离线时执行。

智能账户已经可以强制执行细粒度的委托，但 dapp 一直没有标准方式来**请求**委托。ERC-7715 定义了这种请求，使任何 dapp 都能与任何支持它的钱包对话。

## 它如何运作

dapp 发送 `wallet_requestExecutionPermissions`，附带一个请求数组。每个请求包含：

- `chainId`，以及可选的 `from`（用户的账户）。
- `to`：将使用该权限的 dapp **会话账户（session account）**。
- `permission`：一个带类型的对象，例如带有 `allowance` 的 `native-token-allowance`，以及表示钱包是否可以调整金额的 `isAdjustmentAllowed`。
- `rules`：额外的约束，例如 `expiry` 时间戳。

权限和规则的类型并不由本 ERC 固定；新的类型预计会在各自的 ERC 中定义。

钱包把请求展示给用户，如果获批，则返回该请求（可能经过调整）以及：

- `context`：标识该授权的不透明数据块。
- `delegationManager`：兑现（redeem）该授权的合约（[ERC-7710](/eip-7710/)）。
- `dependencies`：需要先部署的账户所对应的 `factory` / `factoryData` 对（[ERC-4337](/eip-4337/) 风格）。

要使用权限，会话账户需带上 `context` 和它希望用户账户发起的调用的编码，去调用 delegation manager 的 redeem 函数。辅助方法让 dapp 可以列出支持的类型（`wallet_getSupportedExecutionPermissions`）、列出已授予的权限（`wallet_getGrantedExecutionPermissions`）以及撤销某个权限（`wallet_revokeExecutionPermission`）。

## 示例代码

通过 [EIP-1193](/eip-1193/) provider 请求一小时有效的原生代币额度：

```ts
const [grant] = await window.ethereum.request({
  method: "wallet_requestExecutionPermissions",
  params: [
    {
      chainId: "0x1",
      to: sessionAccount.address,           // key held by the dapp
      permission: {
        type: "native-token-allowance",
        isAdjustmentAllowed: true,
        data: { allowance: "0x0DE0B6B3A7640000" }, // 1 ETH in wei
      },
      rules: [
        { type: "expiry", data: { timestamp: Math.floor(Date.now() / 1000) + 3600 } },
      ],
    },
  ],
});

// Keep these to redeem later via ERC-7710
const { context, delegationManager, dependencies } = grant;
```

## 需要注意

- **状态：Draft。**字段和方法名称仍可能变化，而且规范自带的示例也不完全一致（例如 `ruleTypes` 与 `rulesTypes`），因此在依赖确切字段名之前，请查阅钱包的文档。
- 强制执行权限的是钱包，而不是这个 ERC。用户必须信任钱包的实现；规范要求钱包清晰地展示权限，并对危险权限发出警告。
- dapp 应请求范围最窄、有效期很短的权限。泄露的会话密钥可以在过期或被撤销之前使用已授予的一切权限。
- 它是对 [ERC-5792](/eip-5792/)（经用户批准的批量调用）的补充，也不同于更早的 [EIP-2255](/eip-2255/)，后者涉及的是 RPC 方法的权限，而不是链上执行。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7715
