Paymaster API
The basics of Stackup's Paymaster API
Stackup's paymasters allow users to sponsor transactions or accept ERC-20 tokens for gas payment. The full RPC methods can be found in Paymaster RPC Methods. Stackup charges a fee of 5% of the gas price to sponsor transactions. Enterprise plan customers can contact us to share paymaster fee revenue.
Endpoint
https://api.stackup.sh/v1/paymaster/API_KEY
Sponsored Transactions
Using the payg
paymaster type, you can sponsor transactions directly for users. Stackup will fully cover gas for valid UserOperations and the value will be billed to your monthly invoice with Stackup.
ERC-20 Tokens
The erc20token
paymaster type allows you to use ERC-20 tokens for gas payments. Stackup will fully cover gas for valid UserOperations and the Stackup paymaster will withdraw the appropriate ERC-20 token amount at the end of the UserOperation.
ERC-20 withdrawal occurs during the postOp
method. Stackup has various protections to ensure that the Smart Account's ERC-20 token balance does not change between the paymaster agreeing to sponsor the transaction and withdrawing the ERC-20 token. In the rare case a Smart Account bypasses these checks to exploit the paymaster, Stackup will treat it as a sponsored transaction and add the unpaid gas to your monthly invoice.
Want users to pay with your token?
We add new ERC-20 tokens to the paymaster on a case-by-case basis. Please contact us to add your token.
Using userop.js
The easiest way to use paymasters is with the userop.js library to call the Paymaster RPC Methods. As a UserOperation is built using buildOp
, the verifyingPaymaster
middleware can be used to retrieve the paymasterAndData
and required gas limits. See the verifyingPaymaster function for more details and the examples repository for an implementation.
Enable Paymasters
Paymasters are included by default in the Developer, Startup, and Enterprise Plans. This can be enabled on the billing page in the Stackup dashboard.
Contract
Stackup's paymaster contract is on our Github page: https://github.com/stackup-wallet/contracts/blob/main/contracts/VerifyingPaymaster.sol
Updated about 1 year ago