Paymaster Utilities
Essential utilities for using paymasters on ZKsync Era
The paymaster utilities library contains essential utilities for using paymasters on ZKsync Era.
Contract interfaces
IPaymasterFlow
Constant ABI definition for the Paymaster Flow Interface.
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. |
export 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(),
});
Functions
Approval-based Paymaster
Returns encoded input for an approval-based paymaster.
Inputs
| Parameter | Type | Description |
|---|---|---|
paymasterAddress | Address | The non-zero paymaster address. |
paymasterInput | Data | The input data to the paymaster. |
func encodeApprovalBased(_ tokenAddress: EthereumAddress, minimalAllowance: BigUInt, paymasterInput: Data) -> Data
General Paymaster
Returns encoded input for a general paymaster.
Inputs
| Parameter | Type | Description |
|---|---|---|
paymasterInput | Data | The input data to the paymaster. |
func encodeGeneral(_ paymasterInput: Data) -> Data