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.

IPaymasterFlow := abi.JSON(strings.NewReader(paymasterflow.IPaymasterFlowMetaData.ABI));

Functions

GetApprovalBasedPaymasterInput

Returns encoded input for an approval-based paymaster.

Inputs

ParameterTypeDescription
paymasterInputApprovalBasedPaymasterInputThe 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

ParameterTypeDescription
paymasterInputGeneralPaymasterInputThe 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

ParameterTypeDescription
paymasterAddressAddressThe non-zero paymaster address.
paymasterInputPaymasterInputThe 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 exampleopen in new window how to use paymaster.