Gas sponsorship
Gas sponsorship offers a flexible way to manage and control gas payments
Whether you're building a game, marketplace, or any web3 application, these policies give you the tools to create seamless user experiences by controlling how transaction fees are handled.
What's a Gas Manager?#
A gas manager is at the heart of how Openfort handles transaction fees. Think of it as your control center for managing how and when your application will sponsor user's gas fees. You might use it to make onboarding smoother by covering gas fees for new users, let players use in-game tokens for transactions, or encourage specific actions in your ecosystem.
Getting started#
Setting up gas sponsorship is straightforward. Start by visiting the Gas Policy tab in your dashboard and clicking Add Policy
. From there, you'll be able to configure how you want to handle transaction fees.
Sponsoring gas fees#
When it comes to sponsoring gas fees, you have two main approaches available:
Paying with credit card#
The simplest way to get started is by adding balance credit to your account. When you choose this method, gas costs are automatically deducted from your balance as transactions occur. This is particularly useful when you're ready to go live with your project, as it's required for livemode
operations.
Paying with native tokens#
For more advanced use cases, you can use network native tokens (like ETH on Base). This method involves depositing tokens to Openfort's Paymaster contract. Here's how to set it up:
Check the entity addresses page to find the paymaster's address in your network.
Tokens deposited in this contract can always be withdrawn by the owner and you can control its balance at any time checking the its balance.
- First, deposit your tokens using the
depositFor
function:
-
After depositing, head to the backend wallets page to register your EOA wallet.
-
Sign and validate your signature by clicking on advanced configuration (see the video below).
- Finally, configure your policy to use these deposits by selecting "Sponsor gas with your tokens" when editing or creating a policy:
When using a strategy that supports payment in ERC-20 tokens (i.e. charge_custom_tokens
or fixed_rate
), the backend wallet will receive the tokens users pay for gas fees.
Optional: Using external paymasters#
For those needing custom solutions, Openfort supports integration with external paymasters. This feature is particularly useful when you have specific requirements for gas sponsorship that go beyond the standard options. Note that when using external paymasters, you'll need to use the pay_for_user
strategy.
When using an external paymaster, the only supported strategy
is pay_for_user
.
To set up an external paymaster, you can either use the dashboard:
Or configure it through the API:
_10# Create the paymaster object_10curl https://api.openfort.xyz/v1/paymasters/ \_10 -H "Authorization: Bearer $YOUR_SECRET_KEY" \_10 -d address=80002 \_10 -d url="YOUR_PAYMASTER_URL"_10_10# Link it to your policy_10curl https://api.openfort.xyz/v1/policies/:id \_10 -H "Authorization: Bearer $YOUR_SECRET_KEY" \_10 -d paymaster=pay_...
With these fundamentals in place, you're ready to start managing gas fees for your users. The next section will dive deeper into the different types of policies and rules you can create.