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 Managers can be used by dapps or companies to remove the need for users to pay for gas, which significantly enhances the user experience and can help onboard the next generation of web3 users.
The Gas Manager Coverage API is a set of methods to sponsor user operations on behalf of users, and abstracting away the concept of "gas" from them. More information about it is mentioned in the sections below.
To sponsor gas fees for your users, here are the steps you need to follow:
- Create a Gas Policy: Gas policies are rules defining conditions when you want to sponsor someone's gas. Developers can manually create gas policies through the Alchemy dashboard or programmatically through the Gas Manager Admin APIs. Once a policy is created, developers will receive a policy id.
paymasterAndData: When sending a user operation, you can specify the
paymasterAndDatafield in the
userOpobject. 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( recommended ) or
alchemy_requestPaymasterAndDatamethods using your gas policy id. This step uses methods specific to the Gas Manager Coverage API.
- Send the sponsored user operation: Once you get the
paymasterAndData, you can use this in your user operation (
userOp) to sponsor the given
userOp. The Gas Manager will pay for the gas associated with the given user operation when it is mined.
You must make the Gas Manager Coverage API requests with the Alchemy API key associated with the policy’s app.
All the Gas Manager Coverage API endpoints are listed below along with links to their individual pages and brief descriptions.
Requests sponsorship for a
alchemy_requestGasAndPaymasterAndData( Recommended )
paymasterAndDataand the gas fields for the
userOperationif approved, errors if not.
paymasterAndDataif approved, errors if not.