Paymaster utilities


Paymaster utilities

The paymaster utilities libraryopen in new window contains essential utilities for using paymasters on zkSync Era.

Contract interfaces

IPaymasterFlow

Constant ABI definition for the Paymaster Flow Interfaceopen in new window.

export const IPaymasterFlow = new ethers.utils.Interface(require("../../abi/IPaymasterFlow.json").abi);

Functions

getApprovalBasedPaymasterInput

Returns encoded input for an approval-based paymaster.

Inputs

ParameterTypeDescription
paymasterInputApprovalBasedPaymasterInput objectThe input data to the paymaster.
export function getApprovalBasedPaymasterInput(paymasterInput: ApprovalBasedPaymasterInput): BytesLike {
  return IPaymasterFlow.encodeFunctionData("approvalBased", [paymasterInput.token, paymasterInput.minimalAllowance, paymasterInput.innerInput]);
}

getGeneralPaymasterInput

As above but for general-based paymaster.

Inputs

ParameterTypeDescription
paymasterInputGeneralPaymasterInput objectThe input data to the paymaster.
export function getGeneralPaymasterInput(paymasterInput: GeneralPaymasterInput): BytesLike {
  return IPaymasterFlow.encodeFunctionData("general", [paymasterInput.innerInput]);
}

getPaymasterParams

Returns a correctly-formed paymasterParams object for common paymaster flows.

Inputs

ParameterTypeDescription
paymasterAddressAddress stringThe non-zero paymaster address.
paymasterInputPaymasterInput objectThe input data to the paymaster.
export function getPaymasterParams(paymasterAddress: Address, paymasterInput: PaymasterInput): PaymasterParams;

Find out more about the PaymasterInput type.