@biconomy/paymaster

中文文档
3.1.4发布于 2024/10/11MITTypeScriptCommonJS近 30 天下载 2060

Biconomy Paymaster to interact with Paymaster Services that interacts with ( veriying and token ) paymasters

原始使用文档

Paymaster

ERC4337, Account abstraction, introduces the concept of Paymasters. These specialised entities play a pivotal role in revolutionising the traditional gas payment system in EVM transactions. Paymasters, acting as third-party intermediaries, possess the capability to sponsor gas fees for an account, provided specific predefined conditions are satisfied.

Installation

Using npm package manager

npm i @biconomy/paymaster

OR

Using yarn package manager

yarn add @biconomy/paymaster

Usage

// This is how you create paymaster instance in your dapp's
import { IPaymaster, BiconomyPaymaster } from "@biconomy/paymaster";

// Currently this package only exports Biconomy Paymaster which acts as a Hybrid paymaster for gas abstraction. You can sponsor user transactions but can also make users pay gas in supported ERC20 tokens.

const paymaster = new BiconomyPaymaster({
  paymasterUrl: "", // you can get this value from biconomy dashboard. https://dashboard.biconomy.io
});

paymasterUrl you can get this value from biconomy dashboard.

Following are the methods that can be called on paymaster instance

export interface IHybridPaymaster<T> extends IPaymaster {
  getPaymasterAndData(userOp: Partial<UserOperation>, paymasterServiceData?: T): Promise<PaymasterAndDataResponse>;
  buildTokenApprovalTransaction(tokenPaymasterRequest: BiconomyTokenPaymasterRequest, provider: Provider): Promise<Transaction>;
  getPaymasterFeeQuotesOrData(userOp: Partial<UserOperation>, paymasterServiceData: FeeQuotesOrDataDto): Promise<FeeQuotesOrDataResponse>;
}

One can also build their own Paymaster API class and submit a PR or just provide instance of it in the account package / use standalone to generate paymasterAndData

It should follow below Interface.

export interface IPaymaster {
  // Implementing class may add extra parameter (for example paymasterServiceData with it's own type) in below function signature
  getPaymasterAndData(userOp: Partial<UserOperation>): Promise<PaymasterAndDataResponse>;
  getDummyPaymasterAndData(userOp: Partial<UserOperation>): Promise<string>;
}

Below API methods can be used for Biconomy Hybrid paymaster

getPaymasterAndData

This function accepts a Partial<UserOperation> object that includes all properties of userOp except for the signature and paymasterAndData field. It returns paymasterAndData as part of the PaymasterAndDataResponse

buildTokenApprovalTransaction

This function is specifically used for token paymaster sponsorship. The primary purpose of this function is to create an approve transaction for paymaster that gets batched with the rest of your transactions.

Note: You don't need to call this function. It will automatically get called as part of the buildTokenPaymasterUserOp function call.

getPaymasterFeeQuotesOrData

This function is used to fetch quote information or paymaster data based on provided userOperation and paymasterServiceData. If explicit mode is not provided it tries for sponsorship first and then falls back to serving fee quotes for supported/requested token/s

Note: This function can return paymasterAndData as well in case all of the policies checks get passed.

版本与发布记录

@biconomy/paymaster 共发布 15 个版本,首次发布于 2023/07/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.4latest2024/10/112 年前
4.1.12024/03/072 年前
4.1.02024/03/062 年前
4.0.22024/02/272 年前
4.0.12024/02/222 年前
4.0.02024/02/122 年前

关于 @biconomy/paymaster 的常见问题

@biconomy/paymaster 是什么?

Biconomy Paymaster to interact with Paymaster Services that interacts with ( veriying and token ) paymasters

如何安装 @biconomy/paymaster?

在项目目录运行 npm install @biconomy/paymaster,或使用 pnpm add / yarn add / bun add。

@biconomy/paymaster 支持 TypeScript 吗?

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

@biconomy/paymaster 支持 ESM 还是 CommonJS?

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

@biconomy/paymaster 可以商用吗?

@biconomy/paymaster 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@biconomy/paymaster 的下载量有多少?

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

@biconomy/paymaster 还在维护吗?

最新版本 3.1.4 发布于 2024/10/11(2 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/07/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。