Paymaster Utilities
Essential utilities for using paymasters on ZKsync Era
The paymaster utilities library contains essential utilities for using paymasters on ZKsync Era. These utilities facilitate the integration and use of paymaster contracts, providing functions and interfaces to encode inputs and create paymaster parameters.
Contract interfaces
IPaymasterFlow
Constant ABI definition for the Paymaster Flow Interface.
IPaymasterFlow := abi.JSON(strings.NewReader(paymasterflow.IPaymasterFlowMetaData.ABI));
Functions
GetApprovalBasedPaymasterInput
Returns encoded input for an approval-based paymaster.
Inputs
Parameter | Type | Description |
---|---|---|
paymasterInput | ApprovalBasedPaymasterInput | The input data to the paymaster. |
func GetApprovalBasedPaymasterInput(paymasterInput types.ApprovalBasedPaymasterInput) ([]byte, error) {
return paymasterFlowAbi.Pack("approvalBased",
paymasterInput.Token,
paymasterInput.MinimalAllowance,
paymasterInput.InnerInput)
}
GetGeneralPaymasterInput
Returns encoded input for a general-based paymaster.
Inputs
Parameter | Type | Description |
---|---|---|
paymasterInput | GeneralPaymasterInput | The input data to the paymaster. |
func GetGeneralPaymasterInput(paymasterInput types.GeneralPaymasterInput) ([]byte, error) {
return paymasterFlowAbi.Pack("general", paymasterInput)
}
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. |
func GetPaymasterParams(paymasterAddress common.Address, paymasterInput types.PaymasterInput) (*types.PaymasterParams, error)
Find out more about the PaymasterInput
type.
Check out the example on how to use paymaster.