Paymaster
The Paymaster class is a utility class that provides methods for interacting with Paymaster contracts on the zkSync network. It supports two types of Paymasters: ERC20Paymaster and SponsoredPaymaster.
Last updated
The Paymaster class is a utility class that provides methods for interacting with Paymaster contracts on the zkSync network. It supports two types of Paymasters: ERC20Paymaster and SponsoredPaymaster.
Last updated
To call the methods of the Paymaster class, we need to first get the paymaster object.
Creates a new instance of the Paymaster class based on the provided Paymaster contract address.
address
: Address: The address of the Paymaster contract.
runner
: Signer
| Wallet
: A Signer
or Wallet
instance for signing and sending transactions.
Returns
: A new Paymaster
instance.
The Paymaster
class is a utility class that provides methods for interacting with Paymaster contracts on the zkSync network. It supports two types of Paymasters: ERC20Paymaster and SponsoredPaymaster.
address
: Address
- The address of the Paymaster contract.
runner
: Signer
| Wallet
- A Signer
or Wallet
instance for signing transactions.
paymasterType
: - type of Paymaster (ERC20Paymaster or SponsoredPaymaster).
chainId
: string
- The ID of the chain the Paymaster contract is deployed on.
token
: Address
(optional) - The address of the ERC20 token used by the ERC20Paymaster.
Populates a TransactionRequest
object with the necessary data to call a function on a contract using the Paymaster.
contractAddress
: Address
- The address of the contract to call.
functionToCall
: ethers.InterfaceAbi
- The definition of the function to call. Can be:
args
: any[]
(optional) - An array of arguments for the function call.
Returns
: A TransactionRequest
object populated with the transaction data.
Generates the PaymasterParams
object that will be passed to the transaction that's using a paymaster.
Returns
: A PaymasterParams
object.
Populates and sends a transaction using the Paymaster.
contractAddress
: Address
- The address of the contract to call.
functionToCall
: ethers.InterfaceAbi
- The definition of the function to call. Can be:
args
: any[]
(optional) - An array of arguments for the function call.
Returns
: A TransactionResponse
object.
Sends a populated TransactionRequest
object using the Paymaster.
tx
: The TransactionRequest
object to send.
Returns
: A TransactionResponse
object.
Gets the balance of the Paymaster contract.
Returns
: The balance of the Paymaster contract as a BigNumberish
value.
Estimates the gas required for a transaction. Especially tailored for Paymaster paymaster needs.
tx
: The TransactionRequest
object for which to estimate the gas.
Returns
: The estimated gas limit as a BigNumberish
value.
Returns
: An instance of the (ethers.Contract)
.
Adds a restriction to the Paymaster.
address
: Address
- The address of the restriction contract to add.
Returns
: A ContractTransactionResponse
object.
Gets the list of restriction contract addresses added to the Paymaster.
Returns
: An array of restriction contract addresses.
Removes a restriction contract from the Paymaster.
address
: Address
- The address of the restriction contract to remove.
Returns
: A ContractTransactionResponse
object.
Checks if a transaction is eligible to be paid for by the Paymaster, based on the added restrictions.
contractAddress
: Address
- The address of the contract to call.
functionToCall
: ethers.InterfaceAbi
- The definition of the function to call. Can be:
args
: any[]
(optional) - An array of arguments for the function call.
Returns
: true
if the transaction is eligible, false
otherwise.
Calculates the minimal allowance required for an ERC20Paymaster to pay for a transaction.
contractAddress
: Address
- The address of the contract to call.
functionToCall
: ethers.InterfaceAbi
- The definition of the function to call. Can be:
args
: any[]
(optional) - An array of arguments for the function call.
Returns
: The minimal allowance as a BigNumberish
value.
Human-Readable fragment - string which resembles a Solidity signature and is introduced in . For example, function balanceOf(address) view returns (uint)
.
Parsed JSON fragment - instances - JavaScript Object desribed in the .
overrides
: (optional)- An object containing overrides for the transaction (e.g., to, value, data, customData, gasLimit, maxFeePerGas, maxPriorityFeePerGas)
paymasterOptions
: (optional) - An object containing options for the Paymaster (e.g., innerInput, minimalAllowance).
Human-Readable fragment - string which resembles a Solidity signature and is introduced in . For example, function balanceOf(address) view returns (uint)
.
Parsed JSON fragment - instances - JavaScript Object desribed in the .
overrides
: (optional)- An object containing overrides for the transaction (e.g., to, value, data, customData, gasLimit, maxFeePerGas, maxPriorityFeePerGas)
Gets an instance of the ERC20Paymaster or SponsoredPaymaster contract, depending on the .
Human-Readable fragment - string which resembles a Solidity signature and is introduced in . For example, function balanceOf(address) view returns (uint)
.
Parsed JSON fragment - instances - JavaScript Object desribed in the .
overrides
: (optional)- An object containing overrides for the transaction (e.g., to, value, data, customData, gasLimit, maxFeePerGas, maxPriorityFeePerGas)
Human-Readable fragment - string which resembles a Solidity signature and is introduced in . For example, function balanceOf(address) view returns (uint)
.
Parsed JSON fragment - instances - JavaScript Object desribed in the .
overrides
: (optional)- An object containing overrides for the transaction (e.g., to, value, data, customData, gasLimit, maxFeePerGas, maxPriorityFeePerGas)