# Paymaster Flow

The flow of the paymaster enables a smooth process for users to be able to swap without the need for gas. The following process is completely trustless and can enable a user to pay with any ERC-20 token or get his transaction sponsored. Let's break down in detail the whole process into 3 steps.

<figure><img src="https://3129085131-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffg3zJM5ChpTTMyke744p%2Fuploads%2FCjlRPYBED7HmjkhvXDm0%2FAPI%20paymaster%20flow.png?alt=media&#x26;token=76690750-b510-4617-8f9d-9350961fca7b" alt=""><figcaption><p>Full Paymaster Flow</p></figcaption></figure>

### 1. Fetching the **transaction data from the front end**

Our API can be integrated into any front-end for whatever type of transactions whether it's a DEX, NFT marketplace, DeFi protocol, or a gaming dApp. When connected to the front-end, the API retrieves user-requested transaction data. Zyfi then estimates the gas fee on zkSync's network and fetches off-chain the ERC-20 token price chosen by the user for gas payment.&#x20;

The API subsequently completes the transaction data, incorporating the ERC-20 token fee to cover gas costs, and signs a message for the transaction to be accepted by the paymaster. The filled transaction data is sent back to the front-end ready for user approval.

### 2. User signing the reconstructed transaction&#x20;

The front-end then submits the transaction as normal to the user. The user then reviews the details and signs an off-chain transaction containing the updated transaction data. This data grants the paymaster the ERC-20 fee allowance and authorization to engage with Zyfi's paymaster. The possibilities for the transaction are virtually limitless, as long as the user possesses enough of the ERC-20 token to cover the gas fees.

### 3. Transaction Execution

The Zyfi paymaster then receives the transaction data associated with the signature of the user approving the signed transaction data. Zyfi then receives the ERC-20 fee, validates & executes the transaction by paying the gas needed for the transaction.\
\
If you have any questions regarding the flow don't hesitate to contact the team on [Telegram](https://t.me/joinchat/3-fAd9pmy9gwODlk) or [Discord](https://discord.com/invite/KHchZXmv8Q)&#x20;

**If you wish to use the API in your front-end, you can check our documentation:**  [**https://api.zyfi.org/api-doc**](https://api.zyfi.org/api-doc)
