How to Create a Gas Manager Policy

Learn how to configure a gas manager policy from the Alchemy Gas Manager API Dashboard.

What is a Gas Manager Policy?

Gas manager policies are rules defined by companies that govern how and when an application will sponsor a user's gas fees using a paymaster like Alchemy's Gas Manager Coverage API.

An example of spending rules is included in the screenshot below:

Creating a gas policy through Alchemy Dashboard

Creating a gas policy through Alchemy Dashboard

How to Create a Gas Manager Policy

This guide demonstrates the steps to create a gas manager policy. Please note that if you're looking to set up a gas policy on Mainnets, a subscription to the Growth or Enterprise plan is required. Consider upgrading your account if necessary.

Step 1: Create an Account and an Application

Start by creating a new application or using an existing application and the associated chain.

📘

Just testing? Try creating a policy on a testnet!

We advise setting up an application on a test network like Sepolia or Mumbai as your new gas manager policy will directly associate with the application and network.


Step 2: Draft a New Policy

Log in and navigate to the "Gas Policies" section and click the create a policy button.

Create Policy


Step 3: Set the Name and associated App for Gas Policy

Enter the name for your Gas Policy and set the Alchemy App you want to associate with it.

📘

NOTE

A Gas Policy can only be associated with one Alchemy App and it will only accept requests sent through the API key of associated app. All other requests will be rejected.

Define Policy


Step 4: Define the Spending Rules

Click "Next" and set up address levels and global rules if needed.

These rules help limit the amount of money or the number of user ops that can be sent from the gas manager policy.

Creating a gas policy through Alchemy Dashboard

Step 5: Implement an Allowlist or Blocklist

You can set up an address allowlist or blocklist to allow the usage of the gas manager policy to a list of specific addresses, or to exclude a list of certain addresses from the policy.

Allow Blocklist


Step 6: Set the Policy's Duration

Define the duration of your policy, and the sponsorship expiry period, which is the period for which the Gas Manager signature (paymaster data) will remain valid once it is generated.

Policy Duration


Step 7: Publish Your Policy

When your policy is ready, publish it! Your policy becomes live if its date range includes the current time.

Publish Policy

Next Steps: Executing Gas Coverage

To use your gas manager for sponsoring user operations:

  1. Retrieve your policy id and get your supported entry points via eth_supportedEntryPoints.
  2. For each user operation requiring a gas manager, call alchemy_requestGasAndPaymasterAndData or alchemy_requestPaymasterAndData with the user operation details.
  3. Use the returned paymasterAndData in the final user operation and submit it to a bundler using eth_sendUserOperation.
  4. The Gas Manager will then cover the gas fee for the submitted user operation.

What’s Next

Now that you created your first policy it's time to sponsor your first request!

ReadMe