Gas Manager Coverage API Quickstart

The Gas Manager API allows you to sponsor gas fees for your users, removing the biggest barrier to entry.

What is a Gas Manager?

The Gas Manager is an ERC-4337 Verifying Paymaster, an onchain contract that allows one entity to sponsor the gas fees for another entity. Gas fees are a significant barrier to entry for new users of your app. With the Gas Manager, you can remove this barrier by sponsoring gas fees for your users' transactions.

What is the Gas Manager Coverage API?

The Gas Manager Coverage API is a set of methods that allow you to sponsor gas for userOperations, abstracting away the concept of "gas" from your users.

How to Sponsor a userOperation

📘

Note

Please note that using aa-sdk provides the easiest way to sponsor userOperations. Checkout the tutorial on sponsoring UOs with aa-sdk.

To sponsor gas fees for your users using the Gas Manager Coverage API, follow these steps.

1. Create a Gas Manager Policy

A gas manager policy is a set of rules that define which userOps are eligible for gas sponsorship. You can control which operations are eligible for sponsorship by defining rules:

  • Spending rules: limit the amount of money or the number of user ops that can be sponsored by this policy
  • Allowlist: restrict wallet addresses that are eligible for sponsorship. The policy will only sponsor gas for UOs that were sent by addresses on this list.
  • Blocklist: ban certain addresses from receiving sponsorship under this policy
  • Sponsorship expiry period: this is the period for which the Gas Manager signature (paymaster data) will remain valid once it is generated.

To learn more about policy configuration, refer to the guide on setting up a gas manager policy.

Once you have decided on policy rules for your app, create a policy in the Gas Manager dashboard or through the Gas Manager Admin APIs.

Once a policy is created, you will receive a policy id.

2. Get Gas Manager's signature

When sending a user operation, you can specify the paymasterAndData field in the userOp object. This field is the signature of the Gas Manager that validates your sponsorship for the user operation. You can get this field through alchemy_requestGasAndPaymasterAndData using your gas policy id and a userOperation. The Gas Manager signature will be generated if and only the userOperation satisfies the rules defined in your gas policy.

📘

Note:

You must make the Gas Manager Coverage API requests with the Alchemy API key associated with the policy’s app.

3. Send the sponsored userOperation

Once you get the paymasterAndData, you can use this in your userOperation when you call eth_sendUserOperation. The Gas Manager will pay for the gas of the userOperation when it is mined.

ReadMe