Sponsored Paymaster
Available on ZKsync Era mainnet, ZKsync Sepolia, Cronos zkEVM Mainnet, Cronos zkEVM Tesnet, Abstract Tesnet, Abstract Mainnet.
Last updated
Available on ZKsync Era mainnet, ZKsync Sepolia, Cronos zkEVM Mainnet, Cronos zkEVM Tesnet, Abstract Tesnet, Abstract Mainnet.
Last updated
This guide will help you get started with Zyfi API sponsored endpoint to allow custom business logic.
In addition to the standard ERC20 Paymaster flow, it allows a protocol to decide how much of the transaction it wishes to sponsor for an user with their off-chain business logic by setting the sponsorshipRatio. What is not sponsored is paid by the user with the selected feeToken
For advanced usage and detailed explanation of each parameter and feature, please explore our detailed .
The basic flow consists of the following steps:
Deposit ETH in the audited Zyfi Vault contract that will be used to sponsor transactions for your users (Use the to deposit on the correct address)
The deposit transaction generates a corresponding balance in the vault, associated with your wallet address. This balance covers the transaction fees for your users
Get an API-Key
connected to the vault balance (on the )
Collect the transaction payload (similar to the ERC20 Paymaster)
Send an API request with the sponsorship information
Receive back the quote and transaction payload for the user to sign
Send the required data to the erc20_sponsored_paymaster
endpoint. Below an example implementation using Javascript (natively supported in most environments)
The returned object does not change the original transaction calldata, but add the paymaster fields necessary to process the transaction.
The response, on top of the transaction payload, returns a series of helper values that can be used by the UI to better inform the user. In particular:
tokenAddress
: ERC20 token address used to pay for the gas fee (feeToken)
tokenPrice
: the estimated cost of the feeToken
feeTokenAmount
: Max amount of the ERC20 token that the user will pay as fee (before refunds). The user need to have this balance for the transaction to not fail
feeUSD
: Equivalent value of feeTokenAmount in USD
markup
: Markup or discount applied on the gas fee
protocolAddress
: The account in the vault being used to pay for the sponsored part
sponsorshipRatio
: which % of the transaction is sponsored by the protocol
expirationTime
: block.timestamp
of the quote expiration. Currently it's one hour
Below an example implementation with
Ensure you are using V5 or V6.
Make sure to check to enable zkSync specific features