Ethersv6 API
Paymaster Utilities
Essential utilities for using paymasters on ZKsync Era.
The paymaster utilities library provides key utilities for interacting with paymasters on ZKsync Era.
Contract interfaces
Define the constant ABI for the Paymaster Flow Interface:
const PAYMASTER_FLOW_ABI = new ethers.Interface(IPaymasterFlowABI);
Functions
getApprovalBasedPaymasterInput
Returns the encoded input for an approval-based paymaster.
Inputs
Parameter | Type | Description |
---|---|---|
paymasterInput | ApprovalBasedPaymasterInput | The input data to the paymaster. |
function getApprovalBasedPaymasterInput(paymasterInput: ApprovalBasedPaymasterInput): BytesLike;
getGeneralPaymasterInput
Returns the encoded input for a general-based paymaster.
Inputs
Parameter | Type | Description |
---|---|---|
paymasterInput | GeneralPaymasterInput | The input data to the paymaster. |
function getGeneralPaymasterInput(paymasterInput: GeneralPaymasterInput): BytesLike;
getPaymasterParams
Returns a correctly-formed paymasterParams
object for common paymaster flows.
Inputs
Parameter | Type | Description |
---|---|---|
paymasterAddress | Address | The non-zero paymaster address. |
paymasterInput | PaymasterInput | The input data to the paymaster. |
function getPaymasterParams(paymasterAddress: Address, paymasterInput: PaymasterInput): PaymasterParams;
Find out more about the PaymasterInput
type.
Examples
Creating General
paymaster parameters:
const paymasterAddress = "0x0a67078A35745947A37A552174aFe724D8180c25";
const paymasterParams = utils.getPaymasterParams(paymasterAddress, {
type: "General",
innerInput: new Uint8Array(),
});
Creating ApprovalBased
paymaster parameters:
const result = utils.getPaymasterParams("0x0a67078A35745947A37A552174aFe724D8180c25", {
type: "ApprovalBased",
token: "0x65C899B5fb8Eb9ae4da51D67E1fc417c7CB7e964",
minimalAllowance: BigInt(1),
innerInput: new Uint8Array(),
});