# 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="/files/EST9GSeMyLQxRdITWAkx" 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zyfi.org/introduction/paymaster-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
