# @1inch/permit-signed-approvals-utils 中文文档

规范地址：https://npmcn.com/package/%401inch/permit-signed-approvals-utils/

版本：1\.5\.2
npm 元数据更新时间：2026-10-09T15:43:17.193Z
中文译文更新时间：2026-11-06T01:04:29.850Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%401inch/permit-signed-approvals-utils
原文对照：https://npmcn.com/package/%401inch/permit-signed-approvals-utils/?lang=original
项目主页：https://github.com/1inch/permit-signed-approvals-utils#readme

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：109 kB，77 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：1 个
- 首次发布：2021-07-22T09:09:14.543Z
- 最新版本发布：2024-07-15T16:51:45.053Z
- 近 30 天下载量：7483（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：21（近 12 个月 0 个）

## 中文简介

EIP-2612的Utils图书馆:许可证 - 712签名批准

## 安装

```sh
npm install @1inch/permit-signed-approvals-utils
```

也可以使用：`pnpm add @1inch/permit-signed-approvals-utils`、`yarn add @1inch/permit-signed-approvals-utils`、`bun add @1inch/permit-signed-approvals-utils`

## README

![](https://github.com/1inch/permit-signed-approvals-utils/blob/master/.github/workflows/1inch_github_w.svg#gh-light-mode-only) ![](https://github.com/1inch/permit-signed-approvals-utils/blob/master/.github/workflows/1inch_github_b.svg#gh-dark-mode-only)

# EIP-2612的Utils库:基于EIP-712签名批准的许可

这是EIP-2612许可证中用于建立签名和呼叫数据的成套公用事业

## 规格

### [https://eips.ethereum.org/EIPS/eip-2612 (英语)](https://eips.ethereum.org/EIPS/eip-2612)

## 测试覆盖率

| 发言 | 分支 | 职能 | 行数 |
| --- | --- | --- | --- |
| ![Statements](https://img.shields.io/badge/statements-96.06%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-89.39%25-yellow.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-89.74%25-yellow.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-96.06%25-brightgreen.svg?style=flat) |

## 安装

### 节点

```
npm install @1inch/permit-signed-approvals-utils
```

### 雅伦

```
yarn add @1inch/permit-signed-approvals-utils
```

* * *

## 捐款

见 [捐款额](https://github.com/1inch/limit-order-protocol-utils/blob/master/CONTRIBUTING.md)

## 更改日志

见 [变动情况](https://github.com/1inch/limit-order-protocol-utils/blob/master/CHANGELOG.md)

* * *

## 关于

### 构建许可签名

```typescript
import {
    Eip2612PermitUtils,
    Web3ProviderConnector,
    PermitParams,
} from '@1inch/permit-signed-approvals-utils';
import Web3 from 'web3';

const chainId = 1;
const contractAddress = '0x11111112542d85b3ef69ae05771c2dccff4faa26';
const tokenAddress = '0x111111111117dc0aa78b770fa6a738034120c302';
const tokenName = '1INCH Token';
const walletAddress = '0x2c9b2dbdba8a9c969ac24153f5c1c23cb0e63914';
const privateKey =
    '965e092fdfc08940d2bd05c7b5c7e1c51e283e92c7f52bbf1408973ae9a9acb7';

const permitParams: PermitParams = {
    owner: walletAddress,
    spender: contractAddress,
    value: '1000000000',
    nonce: 0,
    deadline: 192689033,
};

const web3 = new Web3('...');
// You can create and use a custom provider connector (for example: ethers)
// For server side, you can use: new PrivateKeyProviderConnector(privateKey, web3);
const connector = new Web3ProviderConnector(web3);
const eip2612PermitUtils = new Eip2612PermitUtils(connector);

const signature = await eip2612PermitUtils.buildPermitSignature(
    {
        ...permitParams,
        nonce: await eip2612PermitUtils.getTokenNonce(
            tokenAddress,
            walletAddress
        ),
    },
    chainId,
    tokenName,
    tokenAddress
);

console.log('Permit signature', signature);
```

### 构建许可调用数据

```typescript
import {
    Eip2612PermitUtils,
    Web3ProviderConnector,
    PermitParams,
} from '@1inch/permit-signed-approvals-utils';
import Web3 from 'web3';

const chainId = 1;
const contractAddress = '0x11111112542d85b3ef69ae05771c2dccff4faa26';
const tokenAddress = '0x111111111117dc0aa78b770fa6a738034120c302';
const tokenName = '1INCH Token';
const walletAddress = '0x2c9b2dbdba8a9c969ac24153f5c1c23cb0e63914';
const privateKey =
    '965e092fdfc08940d2bd05c7b5c7e1c51e283e92c7f52bbf1408973ae9a9acb7';

const permitParams: PermitParams = {
    owner: walletAddress,
    spender: contractAddress,
    value: '1000000000',
    nonce: 0,
    deadline: 192689033,
};

const web3 = new Web3('...');
// You can create and use a custom provider connector (for example: ethers)
// For server side, you can use: new PrivateKeyProviderConnector(privateKey, web3);
const connector = new Web3ProviderConnector(web3);
const eip2612PermitUtils = new Eip2612PermitUtils(connector);

const callData = await eip2612PermitUtils.buildPermitCallData(
    {
        ...permitParams,
        nonce: await eip2612PermitUtils.getTokenNonce(
            tokenAddress,
            walletAddress
        ),
    },
    chainId,
    tokenName,
    tokenAddress
);

console.log('Permit call data', callData);
```

### 从象征性合同中获得非曲直

```typescript
import {
    Eip2612PermitUtils,
    Web3ProviderConnector,
} from '@1inch/permit-signed-approvals-utils';
import Web3 from 'web3';

const tokenAddress = '0x111111111117dc0aa78b770fa6a738034120c302';
const walletAddress = '0x2c9b2dbdba8a9c969ac24153f5c1c23cb0e63914';
const privateKey =
    '965e092fdfc08940d2bd05c7b5c7e1c51e283e92c7f52bbf1408973ae9a9acb7';

const web3 = new Web3('...');
// You can create and use a custom provider connector (for example: ethers)
// For server side, you can use: new PrivateKeyProviderConnector(privateKey, web3);
const connector = new Web3ProviderConnector(web3);
const eip2612PermitUtils = new Eip2612PermitUtils(connector);

const nonce = await eip2612PermitUtils.getTokenNonce(
    tokenAddress,
    walletAddress
);

console.log('Nonce', nonce);
```

### 从调用数据恢复许可证所有者

```typescript
import {
    Eip2612PermitUtils,
    Web3ProviderConnector,
} from '@1inch/permit-signed-approvals-utils';
import Web3 from 'web3';

const callData = '0x......0000';

const chainId = 56;
const tokenName = '1INCH';
const tokenAddress = '0x111111111117dc0aa78b770fa6a738034120c302';
const walletAddress = '0x2c9b2dbdba8a9c969ac24153f5c1c23cb0e63914';
const privateKey =
    '965e092fdfc08940d2bd05c7b5c7e1c51e283e92c7f52bbf1408973ae9a9acb7';

const web3 = new Web3('...');
// You can create and use a custom provider connector (for example: ethers)
// For server side, you can use: new PrivateKeyProviderConnector(privateKey, web3);
const connector = new Web3ProviderConnector(web3);
const eip2612PermitUtils = new Eip2612PermitUtils(connector);

const result = await eip2612PermitUtils.recoverPermitOwnerFromCallData({
    chainId,
    tokenName,
    tokenAddress,
    callData
});

// OR

const syncResult = eip2612PermitUtils.syncRecoverPermitOwnerFromCallData({
    chainId,
    tokenName,
    tokenAddress,
    callData,
    nonce: 1,
});

// OR (for DAI-like tokens)

const daiLikeResult = await eip2612PermitUtils.recoverDaiLikePermitOwnerFromCallData({
    chainId,
    tokenName: 'DAI',
    tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
    callData,
    nonce: 1,
});

console.log('Result', result);
console.log('SyncResult', syncResult);
console.log('DaiLikeResult', daiLikeResult);
```

## 常见问题

### @1inch/permit-signed-approvals-utils 是什么？

EIP-2612的Utils图书馆:许可证 - 712签名批准

### 如何安装 @1inch/permit-signed-approvals-utils？

在项目目录运行 npm install @1inch/permit-signed-approvals-utils，或使用 pnpm add / yarn add / bun add。

### @1inch/permit-signed-approvals-utils 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/1inch\_\_permit-signed-approvals-utils 是否存在。

### @1inch/permit-signed-approvals-utils 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @1inch/permit-signed-approvals-utils 可以商用吗？

@1inch/permit-signed-approvals-utils 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @1inch/permit-signed-approvals-utils 的下载量有多少？

根据 npm 官方下载统计，@1inch/permit-signed-approvals-utils 在 2026/10/05 – 2026/11/03 这 30 天内被下载 7,483 次，日均约 249 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @1inch/permit-signed-approvals-utils 还在维护吗？

最新版本 1\.5\.2 发布于 2024/07/16（2 年前）；至今共发布 21 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/07/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

