Step into the Paymaster Bundler experience.
Account Details
Mint NFTs with Coinbase Paymaster
Guide to Using Smart Wallets with Sponsored Transactions
Paymasters (Sponsored Transactions)
One of the biggest UX enhancements unlocked by Smart Wallet is the ability for app developers to sponsor their users' transactions. If your app supports Smart Wallet, you can start sponsoring your users' transactions by using standardized paymaster service communicationenabled by new wallet RPC methods. This code is also in our Wagmi Smart Wallet template.
1. Choose a Paymaster Service Provider
As a prerequisite, you'll need to obtain a paymaster service URL from a paymaster service provider. To be compatible with Smart Wallet, the paymaster provider you choose must be ERC-7677-compliant.
We recommend the Coinbase Developer Platform paymaster. You can find a full list of ERC-7677-compliant paymaster services here.
Once you choose a paymaster service provider and obtain a paymaster service URL, you can proceed to integration.
2. (Recommended) Set Up Your Paymaster Proxy
Creating an API to proxy calls to your paymaster service is important for two reasons:
- It allows you to protect any API secret.
- It allows you to add extra validation on what requests you want to sponsor.
Validate UserOperation
Before we write our proxy, let's write a willSponsor function to add some extra validation. The policies on many paymaster services are quite simple and limited. As your API will be exposed on the web, you want to make sure it cannot be abused: called to sponsor transactions you do not want to fund. The checks below are a bit tedious, but highly recommended to be safe. See "Trust and Validation" here for more on this. The code below is built specifically for Smart Wallets; it would need to be updated to support other smart accounts.
...
Create Proxy
The proxy you create will need to handle the pm_getPaymasterStubData and pm_getPaymasterData JSON-RPC requests specified by ERC-7677.
...
3. Send EIP-5792 Requests with a Paymaster Service Capability
Once you have your paymaster service set up, you can now pass its URL along to Wagmi's useWriteContracts hook. If you set up a proxy in your app's backend as recommended in step (2) above, you'll want to pass in the proxy URL you created.
...
That's it! Smart Wallet will handle the rest. If your paymaster service is able to sponsor the transaction, Smart Wallet will indicate to your user that the transaction is sponsored.
See full documentation here: Smart Wallet Documentation