@gnosispay/account-kit

中文文档
5.2.1发布于 2026/11/12Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 1.1万

软件开发包,可促进与链式Gnosis Pay账户的互动.

中文使用文档
文档目录10 节
  1. 目录
  2. 账户创建
  3. 直接转让
  4. 账户设置
  5. 执行
  6. 限制
  7. 花费
  8. 账户查询
  9. 贡献者
  10. 许可证

帐号包

软件开发包,可促进与链式Gnosis Pay账户的互动.

对于每个账户动作,这种SDK提供了充值交易有效载荷的功能. 生成的交易可以被转发,不需要额外的签名.

目录

账户创建

创建新的 1/1 保险箱 .

import { populateAccountCreation } from "@gnosispay/account-kit";

const createTx = populateAccountCreation({
  owner: `0x<address>`,
});
await relayer.sendTransaction(createTx);

直接转让

签署账户中的 ERC20 令牌转出 。 用于新创建的 1/1 保险箱(设置前). 人口交易已准备就绪,不需要额外签字.

import { populateDirectTransfer } from "@gnosispay/account-kit";

const owner : Signer = {};
const nonce = `<number>`; // see Account Setup section, nonce comment

const transaction = await populateDirectTransfer(
  { safe: `0x<address>`, chainId: `<number>`, nonce: nonce },
  { token: `0x<address>`, to: `0x<address>`, amount: `<bigint>` },
  // callback that wraps an eip-712 signature by owner
  ({ domain, primaryType, types, message }) => owner.signTypedData(...)
);

await relayer.sendTransaction(transaction);

账户设置

将1/1保险箱升级为Gnosis支付账户。 人口交易已准备就绪,不需要额外签字.

import {
  createSetupConfig, populateAccountSetup,
} from "@gnosispay/account-kit";

const owner: Signer = {};
/*
 * NOTE: on the nonce argument for "Account Setup":
 * Unlike limit, spend or execute, this operation is performed on a basic safe.
 * As a result, it depends on safe-core signatures and the safe-core nonce.
 * Must query the on-chain safe nonce value and use it to sign the transaction.
 *
 * In contrast, limit/spend/execute actions run on Zodiac Modifier signatures,
 * which use signer-proposed salts for replay protection and do not require
 * on-chain querying of the nonce.
 */
const nonce = `<number>`;

const config: SetupConfig = createSetupConfig({
  token: `0x<address>`, chainId: `<number>`
})

const transaction = await populateAccountSetup(
  {
    account: `0x<address>`,
    owner: owner.address,
    chainId: `<number>`,
    nonce: nonce
  },
  config,
  // callback that wraps an eip-712 signature !!owner signs!!
  ({ domain, primaryType, types, message }) => owner.signTypedData(...)
);

await relayer.sendTransaction(transaction);

执行

此函数生成一个有效载荷来启动“ 延迟模式” 队列中的交易执行 。 冷却期过后,交易可以执行. 人手交易已准备就绪,不需要再签字.

import {
  populateExecuteEnqueue,
  populateExecuteDispatch,
} from "@gnosispay/account-kit";

const owner : Signer = {};
const innerTransaction = {
  to: `0x<address>`,
  value: `<bigint>`,
  data: `0x<bytes>`
};

const enqueueTx = await populateExecuteEnqueue(
 { account: `0x<address>`, chainId: `<number>` },
  innerTransaction,
  // callback that wraps an eip-712 signature !!owner signs!!
  ({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(enqueueTx);

// ⏳ wait cooldown seconds ⏳

const dispatchTx = populateExecuteDispatch(
  { account },
  innerTransaction
);
await relayer.sendTransaction(dispatchTx);

限制

此函数生成一个有效载荷, 启动“ 延迟模式” 队列中的允许变化 。 冷却期过后,可以实行津贴变更. 所有人对津贴配置保持单方面控制。 人手交易已准备就绪,不需要再签字.

import {
  populateLimitEnqueue,
  populateLimitDispatch,
} from "@gnosispay/account-kit";

const owner : Signer = {};
const allowanceConfig : AllowanceConfig = {
  period: `<number>`, // duration, in seconds
  refill: `<bigint>`, // amount added to balance, per period
};

const enqueueTx = await populateLimitEnqueue(
  { account: `0x<address>`, chainId: `<number>` },
  allowanceConfig,
  // callback that wraps an eip-712 signature !!owner signs!!
  ({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(enqueueTx);

// ⏳ wait cooldown seconds ⏳

const dispatchTx = populateLimitDispatch(
  { account: `0x<address>` },
  allowanceConfig
);
await relayer.sendTransaction(dispatchTx);

花费

此函数生成执行付款时要提交的耗用的有效载荷。 通过每个账户的"角色模式",支出者只要不超出设定的"津贴"限额,就可以单方面使用. 人口交易已准备就绪,不需要额外签字.

import { populateSpend } from "@gnosispay/account-kit";

const delegate: Signer = {}; // the spend delegate, configured in the Gnosis Pay Spender Safe
const transfer: Transfer = {
  token: `0x<address>`,
  to: `0x<address>`,
  amount: `<bigint>`,
};

const spendTx = await populateSpend(
  { account: `0x<address>`, spender: `0x<address>`, chainId: `<number>` },
  transfer,
  // callback that wraps an eip-712 signature !!spender signs!!
  ({ domain, primaryType, types, message }) => spender.signTypedData(...)
);
await relayer.sendTransaction(spendTx);

账户查询

这个函数生成一个多调有效载荷,收集所有必要的数据来评价给定的Gnosis Pay账户是否符合完整性要求. 然后,它返回一个完整性状态代码以及应计津贴余额.

import { accountQuery } from "@gnosispay/account-kit";

const {
  status,
  allowance: { balance, refill, period, maxRefill, nextRefill },
} = await accountQuery(
  { account: `0x<address>`, cooldown: `<number>` },
  // a function that receives a tx and performs eth_call, library agnostic
  ({ to, data }) => provider.send("eth_call", [{ to, data }])
);

贡献者

许可证

这个项目根据Apache许可证2.0获得许可——见 自由主义 详细文件.

版本与发布记录

@gnosispay/account-kit 共发布 35 个版本,首次发布于 2023/09/02;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/11/124 天前
5.1.12026/06/055 个月前
5.1.02026/06/045 个月前
5.0.12026/06/035 个月前
5.0.02026/06/035 个月前
4.10.12025/10/201.1 年前

关于 @gnosispay/account-kit 的常见问题

@gnosispay/account-kit 是什么?

软件开发包,可促进与链式Gnosis Pay账户的互动.

如何安装 @gnosispay/account-kit?

在项目目录运行 npm install @gnosispay/account-kit,或使用 pnpm add / yarn add / bun add。

@gnosispay/account-kit 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gnosispay/account-kit 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gnosispay/account-kit 可以商用吗?

@gnosispay/account-kit 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@gnosispay/account-kit 的下载量有多少?

根据 npm 官方下载统计,@gnosispay/account-kit 在 2026/10/17 – 2026/11/15 这 30 天内被下载 10,968 次,日均约 366 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gnosispay/account-kit 还在维护吗?

最新版本 5.2.1 发布于 2026/11/12(4 天前);至今共发布 35 个版本,其中过去 12 个月发布了 5 个;首次发布于 2023/09/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。