Paymaster utilities
Paymaster utilities
The paymaster utilities library contains essential utilities for using paymasters on zkSync Era.
Contract interfaces
IPaymasterFlow
Constant ABI definition for the Paymaster Flow Interface.
export const IPaymasterFlow = new ethers.utils.Interface(require('../../abi/IPaymasterFlow.json').abi);
Functions
getApprovalBasedPaymasterInput
Returns encoded input for an approval-based 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.
export function getGeneralPaymasterInput(paymasterInput: GeneralPaymasterInput): BytesLike {
return IPaymasterFlow.encodeFunctionData('general', [paymasterInput.innerInput]);
}
getPaymasterParams
Returns a correctly-formed paymasterParams
object for common paymaster flows.
export function getPaymasterParams(paymasterAddress: Address, paymasterInput: PaymasterInput): PaymasterParams
Find out more about the PaymasterInput
type.