Paymaster

Creating a Paymaster

Now you can enable your community to interact with your smart contracts freely. They will not need crypto to mint, vote on your DAOs, or receive free airdrops.

  1. Go to the Bitte Wallet

  2. Head to the APPs tab

  3. Click "New Paymaster"

  1. Enter the contract you want to sponsor on NEAR

  2. Functions will appear below that you can toggle to enable or disable functionalities you want your users to run for free.

  1. Fund your paymaster wallet with enough funds to sponsor gas for transactions

The paymaster is now successfully created and will automatically fund the transactions defined before!

Using the paymaster

There are currently 2 ways to use the paymaster, either directly through the wallet or via code.

Using Paymaster Via Wallet

In the previous example, I created a sponsorship for the contract blackdragon.tkn.near and selected the method "ft_transfer". Now, their gas fee will be sponsored whenever someone transacts that contract/method through the wallet.

This makes it easy to use, by adding a wallet connection to any application users can be redirected to Bitte to sign transactions at which point the sponsorship will take effect.

Currently, the sponsorship will affect all the transactions in the wallet. Still, the plan is for the following versions to allow for passing in certain parameters only to allow certain user bases to take advantage of it.

Using Paymaster with Code

To use the paymaster via code you must have access to accounts from within your application to be able to sign transactions to be sponsored.

Start by copying the relayer URL from the dashboard.

The next step involves building the transaction and sending it to that URL via a post request, you can check the official near docs for more information or use this simple wrapper library to get started

You can restrict access to your Paymaster by generating an api key in the dashboard. When using near relay you can add it to .env as BITTE_API_KEY. For direct HTTP requests, include the key in the headers as bitte-api-key.

pnpm i @near-relay/client
import { relayTransaction } from "@near-relay/client";

/**
 * Signs a transaction and sends it to a relayer to get dispatched
 *
 * @param {Action[]} action - The list of actions to include in the transaction.
 * @param {string} receiverId - The ID of the receiver.
 * @param {string} relayerUrl - Url for the relayer to which the tx will be sent
 * @param {Account?} account - Optionally pass in local account
 * @param {string?} network - 'mainnet | testnet'
 * @returns {Promise<any>} - Most likely a receipt (depends on format being returned by relayer).
 */

const receipt = await relayTransaction(action: Action | Action[], receiverId: string, relayerUrl: string, network: string, account: Account)

Managing paymaster

Go to your dashboard to review the account ID, API call URL, and the total sponsored amount. Then, click "Edit" to make any necessary changes.

Editing

Here you can change the smart contract you have selected or change the affected methods.

Deleting

At the bottom of the edit page, you will find a delete button that will allow you to delete the near account associated with the paymaster automatically giving all of the funds contained in it back to your account.

Managing Balance

When viewing the dashboard hit the manage balance button to deposit or withdraw funds, here you can toggle the top tab to fund or withdraw from the near account that is associated with the paymaster.

FAQ

Can I set spending limits on the gas fees my Paymaster covers?

Not directly. The way you would do that at this point would be to only fund the relayer with the amount you are willing to spend

Is it possible to sponsor specific users or groups using the Paymaster?

This feature is planned soon TM

What happens if my Paymaster wallet runs out of funds?

When the user tries to submit the transaction, they will be prompted to pay gas as normal.

Can I sponsor multiple contracts with a single Paymaster?

No. You can currently set this up by managing more than one Paymaster.

Can I track the transactions that have been sponsored by my Paymaster?

Yes, in the dashboard, you can see the amount that has been sponsored. Eventually, there could be better visualization tools.

Is there a limit to the number of transactions my Paymaster can sponsor?

Not currently but there is a limit for the amount of gas that can be sponsored before KYC is necessary.

Can I sponsor account creation?

Account creation is just a function call so technically, you could but at this point that would affect all users of the wallet, this will be possible to do more conveniently once you can limit usage to certain groups of users.

Last updated

Logo