- Batch multi-step transactions
- Create custom gasless experiences
- Sponsor up to $15k monthly on mainnet (unlimited on testnet)
If you need an increase in your sponsorship limit, please reach out on Discord!
Objectives
- Configure security measures to ensure safe and reliable transactions.
- Manage and allocate resources for sponsored transactions.
- Subsidize transaction fees for users, enhancing the user experience by making transactions free.
- Set up and manage sponsored transactions on various schedules, including weekly, monthly, and daily cadences.
Prerequisites
This tutorial assumes you have:-
A Coinbase Cloud Developer Platform Account
If not, sign up on the CDP site. Once you have your account, you can manage projects and utilize tools like the Paymaster. -
Familiarity with Smart Accounts and ERC 4337
Smart Accounts are the backbone of advanced transaction patterns (e.g., bundling, sponsorship). If you’re new to ERC 4337, check out external resources like the official EIP-4337 explainer before starting. -
Foundry
Foundry is a development environment, testing framework, and smart contract toolkit for Ethereum. You’ll need it installed locally for generating key pairs and interacting with smart contracts.
Testnet vs. Mainnet
If you prefer not to spend real funds, you can switch to Base Sepolia (testnet). The steps below are conceptually the same. Just select Base Sepolia in the Coinbase Developer Platform instead of Base Mainnet, and use a contract deployed on Base testnet for your allowlisted methods.
If you prefer not to spend real funds, you can switch to Base Sepolia (testnet). The steps below are conceptually the same. Just select Base Sepolia in the Coinbase Developer Platform instead of Base Mainnet, and use a contract deployed on Base testnet for your allowlisted methods.
Set Up a Base Paymaster & Bundler
In this section, you will configure a Paymaster to sponsor payments on behalf of a specific smart contract for a specified amount.- Navigate to the Coinbase Developer Platform.
- Create or select your project from the upper left corner of the screen.
- Click on the Paymaster tool from the left navigation.
- Go to the Configuration tab and copy the RPC URL to your clipboard — you’ll need this shortly in your code.
Screenshots
- Selecting your project

- Navigating to the Paymaster tool

- Configuration screen

Allowlist a Sponsorable Contract
- From the Configuration page, ensure Base Mainnet (or Base Sepolia if you’re testing) is selected.
- Enable your paymaster by clicking the toggle button.
- Click Add to add an allowlisted contract.
- For this example, add
0x83bd615eb93eE1336acA53e185b03B54fF4A17e8
, and add the functionmintTo(address)
.

Use your own contract
We use a simple NFT contract on Base mainnet as an example. Feel free to substitute your own.
We use a simple NFT contract on Base mainnet as an example. Feel free to substitute your own.
Global & Per User Limits
Scroll down to the Per User Limit section. You can set:- Dollar amount limit or number of UserOperations per user
- Limit cycles that reset daily, weekly, or monthly
max USD
to$0.05
max UserOperation
to1
Limit Cycles
These reset based on the selected cadence (daily, weekly, monthly).
These reset based on the selected cadence (daily, weekly, monthly).
$0.07
so that once the entire paymaster has sponsored $0.07 worth of gas (across all users), no more sponsorship occurs unless you raise the limit.

Test Your Paymaster Policy
Now let’s verify that these policies work. We’ll:- Create two local key pairs (or use private keys you own).
- Generate two Smart Accounts.
- Attempt to sponsor multiple transactions to see your policy in action.
Installing Foundry
- Ensure you have Rust installed
- Install Foundry
- Verify it works
If you see Foundry usage info, you’re good to go!
Create Your Project & Generate Key Pairs
- Make a new folder and install dependencies,
viem
andpermissionless
: - Generate two key pairs with Foundry:
You’ll see something like:Store these private keys somewhere safe
Project Structure With Environment Variables
Create a.env
file in the sponsored_transactions
directory. In the .env
, you’ll add the rpcURL for your paymaster and the private keys for your accounts:
Find your Paymaster & Bundler endpointThe Paymaster & Bundler endpoint is the URL for your Coinbase Developer Platform (CDP) Paymaster.
This was saved in the previous section and follows this format:
https://api.developer.coinbase.com/rpc/v1/base/<SPECIAL-KEY>
Navigate to the Paymaster Tool and select the Configuration
tab at the top of the screen to obtain your RPC URL.Secure your endpointsYou will create a constant for our Paymaster & Bundler endpoint obtained from cdp.portal.coinbase.com. The most secure way to do this is by using a proxy. For the purposes of this demo, hardcode it into our
index.js
file. For product, we highly recommend using a proxy service.Never commit
.env
files to a public repo!Example index.js
Below is a full example of how you might structure index.js
.
index.js
node index.js
from your project root.
Hitting Policy Limits & Troubleshooting
-
Per-User Limit
If you see an error like:That means you’ve hit your UserOperation limit for a single account. Return to the Coinbase Developer Platform UI to adjust the policy. -
Global Limit
If you repeatedly run transactions and eventually see:You’ve hit the global limit of sponsored gas. Increase it in the CDP dashboard and wait a few minutes for changes to take effect.
Verifying Token Ownership (Optional)
Want to confirm the token actually minted? You can read the NFT’sbalanceOf
function:
Conclusion
In this tutorial, you:- Set up and configured a Base Paymaster on the Coinbase Developer Platform.
- Allowlisted a contract and specific function (
mintTo
) for sponsorship. - Established per-user and global sponsorship limits to control costs.
- Demonstrated the sponsorship flow with Smart Accounts using
permissionless
,viem
, and Foundry-generated private keys.
Next Steps
- Use a proxy service for better endpoint security.
- Deploy your own contracts and allowlist them.
- Experiment with bundling multiple calls into a single sponsored transaction.
References
- list of factory addresses
- Discord
- CDP site
- Coinbase Developer Platform
- UI
- proxy service
- Paymaster Tool
- Foundry Book installation guide
- simple NFT contract