Python API

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

PaymasterFlowEncoder

Constant ABI definition for the Paymaster Flow Interface.

encoder = PaymasterFlowEncoder(zk_web3)

Functions

encodeApprovalBased

Returns encoded input for an approval-based paymaster.

Inputs

ParameterTypeDescription
addressHexStrThe token address of the paymaster.
min_allowanceintThe minimal amount of token that can be used to pay fee.
inner_inputbytesThe input data to the paymaster.
paymaster_params = PaymasterParams(**{
    "paymaster": paymaster_address,
    "paymaster_input": zk_web3.to_bytes(
        hexstr=PaymasterFlowEncoder(zk_web3).encode_approval_based(token_address, 1, b''))
})

encode_general

As above but for general-based paymaster.

Inputs

ParameterTypeDescription
inputsbytesThe input data to the paymaster.
paymaster_params = PaymasterParams(**{
    "paymaster": paymaster_address,
    "paymaster_input": zk_web3.to_bytes(
        hexstr=PaymasterFlowEncoder(zk_web3).encode_general( b''))
})

Find out more about the PaymasterParams type. Check out the example on how to use paymaster.


Made with ❤️ by the ZKsync Community