> For the complete documentation index, see [llms.txt](https://help.tokenpocket.pro/developer-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.tokenpocket.pro/developer-cn/agentic-wallet/eip-7715-account-with-permissions/ke-yong-quan-xian/yuan-sheng-dai-bi-quan-xian.md).

# 原生代币权限

TokenPocket 支持原生币（ETH、BNB、POL 等）的两种执行权限：**周期性（periodic）** 与 **流式（stream）**。与 ERC-20 权限类似，但 `permission.data` 中无需 `tokenAddress`。

### 公共字段 <a href="#e5-85-ac-e5-85-b1-e5-a-d-97-e6-ae-b5" id="e5-85-ac-e5-85-b1-e5-a-d-97-e6-ae-b5"></a>

| 字段              | 说明                              |
| --------------- | ------------------------------- |
| `justification` | 展示给用户的授权说明                      |
| `chainId`       | hex 字符串，如 `"0x38"` 表示 BNB Chain |

金额均使用 hex 编码的最小单位（通常为 18 位 wei）。

***

### 原生币周期性权限 `native-token-periodic` <a href="#e5-8e-9f-e7-94-9f-e5-b8-81-e5-91-a8-e6-9c-9f-e6-80-a7-e6-9d-83-e9-99-90-native-token-periodic" id="e5-8e-9f-e7-94-9f-e5-b8-81-e5-91-a8-e6-9c-9f-e6-80-a7-e6-9d-83-e9-99-90-native-token-periodic"></a>

每个周期内允许转出的最大原生币数量；新周期重置额度。

#### 适用场景 <a href="#e9-80-82-e7-94-a8-e5-9c-ba-e6-99-af" id="e9-80-82-e7-94-a8-e5-9c-ba-e6-99-af"></a>

* 每日 Gas 补贴上限
* 周期性原生币定投
* 限制 Relayer 每日可提走的 BNB/ETH 数量

#### `permission.data` 字段 <a href="#permissiondata-e5-a-d-97-e6-ae-b5" id="permissiondata-e5-a-d-97-e6-ae-b5"></a>

| 字段               | 类型       | 说明           |
| ---------------- | -------- | ------------ |
| `periodAmount`   | hex      | 每周期最大额度（wei） |
| `periodDuration` | `number` | 周期长度（秒）      |
| `justification`  | `string` | 授权说明         |

#### 示例：每日 0.01 BNB <a href="#e7-a4-ba-e4-be-8b-e6-af-8f-e6-97-a5-001-bnb" id="e7-a4-ba-e4-be-8b-e6-af-8f-e6-97-a5-001-bnb"></a>

```typescript
import { parseUnits, toHex } from "viem";

const expiry = Math.floor(Date.now() / 1000) + 7 * 86400;

await provider.request({
  method: "wallet_requestExecutionPermissions",
  params: [
    {
      chainId: "0x38",
      to: sessionAddress,
      permission: {
        type: "native-token-periodic",
        isAdjustmentAllowed: true,
        data: {
          periodAmount: toHex(parseUnits("0.01", 18)),
          periodDuration: 86400,
          justification: "允许 DApp/Agent 每日最多转出 0.01 BNB",
        },
      },
      rules: [{ type: "expiry", data: { timestamp: expiry } }],
    },
  ],
});
```

#### Redeem 执行内容 <a href="#redeem-e6-89-a7-e8-a1-8c-e5-86-85-e5-ae-b9" id="redeem-e6-89-a7-e8-a1-8c-e5-86-85-e5-ae-b9"></a>

原生币转账通过 `execution` 结构直接携带 `value`：

```typescript
const execution = {
  target: payeeAddress,
  value: amountInWei,
  callData: "0x",
};
```

***

### 原生币流式权限 `native-token-stream` <a href="#e5-8e-9f-e7-94-9f-e5-b8-81-e6-b5-81-e5-bc-8f-e6-9d-83-e9-99-90-native-token-stream" id="e5-8e-9f-e7-94-9f-e5-b8-81-e6-b5-81-e5-bc-8f-e6-9d-83-e9-99-90-native-token-stream"></a>

原生币额度按秒线性释放，规则与 ERC-20 stream 相同，仅不涉及 token 合约。

#### 适用场景 <a href="#e98082e794a8e59cbae699af-1" id="e98082e794a8e59cbae699af-1"></a>

* 流式 Gas 赞助
* 按时间释放的质押奖励自动提取
* 平滑限流的原生币自动支付

#### `permission.data` 字段 <a href="#permissiondata-e5ad97e6aeb5-1" id="permissiondata-e5ad97e6aeb5-1"></a>

| 字段                | 类型       | 说明           |
| ----------------- | -------- | ------------ |
| `initialAmount`   | hex      | 起始可用额度（wei）  |
| `maxAmount`       | hex      | 累计上限（wei）    |
| `amountPerSecond` | hex      | 每秒新增额度（wei）  |
| `startTime`       | `number` | 开始时间（Unix 秒） |
| `justification`   | `string` | 授权说明         |

#### 示例：流式 ETH 授权 <a href="#e7-a4-ba-e4-be-8b-e6-b5-81-e5-bc-8f-eth-e6-8e-88-e6-9d-83" id="e7-a4-ba-e4-be-8b-e6-b5-81-e5-bc-8f-eth-e6-8e-88-e6-9d-83"></a>

```typescript
import { parseUnits, toHex } from "viem";

const now = Math.floor(Date.now() / 1000);

await provider.request({
  method: "wallet_requestExecutionPermissions",
  params: [
    {
      chainId: "0x1",
      to: sessionAddress,
      permission: {
        type: "native-token-stream",
        isAdjustmentAllowed: false,
        data: {
          initialAmount: toHex(parseUnits("0.001", 18)),
          maxAmount: toHex(parseUnits("0.1", 18)),
          amountPerSecond: toHex(parseUnits("0.00001", 18)),
          startTime: now,
          justification: "流式 ETH 授权，用于自动化 Gas 补贴",
        },
      },
      rules: [{ type: "expiry", data: { timestamp: now + 30 * 86400 } }],
    },
  ],
});
```

#### 额度计算 <a href="#e9-a2-9d-e5-ba-a6-e8-ae-a1-e7-ae-97" id="e9-a2-9d-e5-ba-a6-e8-ae-a1-e7-ae-97"></a>

与 ERC-20 stream 一致：

```
可用 = min(initialAmount + amountPerSecond × (now - startTime), maxAmount) - 已使用
```
