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
Parameter | Type | Description |
---|---|---|
address | HexStr | The token address of the paymaster. |
min_allowance | int | The minimal amount of token that can be used to pay fee. |
inner_input | bytes | The 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
Parameter | Type | Description |
---|---|---|
inputs | bytes | The 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.