# Paymaster

1. **User Transaction Initiation**: A whitelisted user initiates a transaction on the blockchain but does not supply the gas fee.
2. **Paymaster Intervention**: The Paymaster account detects this transaction. It verifies if the user is on the whitelist and the transaction is valid.
3. **Gas Fee Payment**: If the conditions are met, the Paymaster uses its funds to pay the gas fee required for the transaction.
4. **Transaction Completion**: The transaction is processed on the blockchain, thanks to the Paymaster covering the cost.&#x20;

The main advantage of the Paymaster feature is that it removes the burden of gas fees from individual users, especially beneficial in scenarios where users might not have the means or wish to spend their own cryptocurrency on transaction fees. This system is particularly advantageous for companies looking to onboard new users who are unfamiliar with blockchain technology or for applications aiming to provide a more user-friendly experience. By covering transaction fees, companies can encourage more frequent and frictionless interactions on their platform.

<figure><img src="https://4278674505-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmaXag665v6LhjJH7XMxS%2Fuploads%2FWojQ7pWGbZRyHTTjGcdb%2FInstagram%20post%20-%202.png?alt=media&#x26;token=8de5fb58-47d4-43f4-931b-0bf842a921e1" alt=""><figcaption><p>How gas fees is sponsored using Paymaster in Mirai Smart Wallet</p></figcaption></figure>

<table><thead><tr><th>Methods</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-typescript"><code class="lang-typescript">addWhitelist(accountAddress: string, chainId: number): Promise&#x3C;any>
</code></pre></td><td>To add a whitelist using the specified accountAddress and chainId.</td></tr><tr><td><p></p><pre class="language-typescript"><code class="lang-typescript">checkWhitelist(accountAddress: string, sponsorAddress: string, chainId: number)
</code></pre></td><td>To check a whitelist using the specified accountAddress, sponsorAddress and chainId.</td></tr><tr><td><p></p><pre class="language-typescript"><code class="lang-typescript">deposit(amount: string, chainId: number)
</code></pre></td><td>To deposit using the specified amount and chainId.</td></tr><tr><td><p></p><pre class="language-typescript"><code class="lang-typescript">getSponsorBalance(sponsorAddress: string, chainId: number): Promise&#x3C;any>
</code></pre></td><td>To get a sponsor balance using the specified sponsorAddress and chainId.</td></tr><tr><td><p></p><pre class="language-typescript"><code class="lang-typescript">removeWhitelist(accountAddress: string, chainId: number)
</code></pre></td><td>To remove a whitelist using the specified accountAddress, sponsorAddress and chainId.</td></tr></tbody></table>

```typescript
 * @param apiKey - Contact kanalabs to obtain the API key for authentication.
```
