Gas Sponsorship
Volr SDK supports gas sponsorship through Account Abstraction, allowing you to pay gas fees for your users.
What is Gas Sponsorship?
Gas sponsorship means you (the developer) pay the gas fees for user transactions instead of requiring users to hold native tokens (ETH, MATIC, etc.).
Benefits
- Better UX: Users don't need to hold native tokens
- Lower barrier: Users can pay with any supported token
- Seamless experience: Transactions just work without extra steps
How It Works
[User initiates payment]
↓
[Transaction created]
↓
[Gas fee calculated]
↓
[Gas sponsored by developer]
↓
[Transaction executed]
↓
[User pays only the payment amount]
Enabling Gas Sponsorship
Gas sponsorship is configured in your Volr Dashboard:
- Go to Settings > Gas Sponsorship
- Enable gas sponsorship for your project
- Configure sponsorship settings:
- Maximum gas per transaction
- Daily gas limit
- Allowed chains
Account Abstraction
Volr SDK uses Account Abstraction (EIP-4337 / EIP-7702) to enable gas sponsorship:
- Smart Contract Wallets: Each user has a smart contract wallet
- Paymaster: Volr acts as paymaster to sponsor gas
- Seamless: Users don't need to know about gas sponsorship
Gas Sponsorship Status
Check if gas sponsorship is enabled:
import { useVolr } from '@volr/react';
function GasSponsorshipStatus() {
const { config } = useVolr();
// Gas sponsorship is handled automatically
// Users don't need to do anything special
return (
<div>
Gas sponsorship is enabled automatically
</div>
);
}
Monitoring Gas Usage
Monitor gas usage in your Dashboard:
- Go to Analytics > Gas Usage
- View gas usage metrics:
- Total gas sponsored
- Average gas per transaction
- Daily gas costs
Gas Limits
Configure gas limits to control costs:
Per Transaction Limit
Set maximum gas per transaction:
Max Gas per Transaction: 100,000 gas
Daily Limit
Set daily gas sponsorship limit:
Daily Gas Limit: 1,000,000 gas
Chain Limits
Set limits per chain:
Base: 500,000 gas/day
Polygon: 500,000 gas/day
Best Practices
1. Set Reasonable Limits
Set gas limits based on your use case:
// For small payments
Max Gas per Transaction: 50,000
// For complex transactions
Max Gas per Transaction: 200,000
2. Monitor Usage
Regularly check gas usage:
- Review daily gas costs
- Identify high-gas transactions
- Optimize if needed
3. Use Appropriate Chains
Choose chains with lower gas costs:
- Base: Low gas costs, good for high-volume
- Polygon: Very low gas costs
- Arbitrum: Low gas costs, good performance
Gas Sponsorship vs User Pays
Gas Sponsorship (Recommended)
- ✅ Better UX
- ✅ Lower barrier to entry
- ✅ Users pay only the payment amount
- ❌ You pay gas fees
User Pays Gas
- ✅ You don't pay gas fees
- ❌ Users need native tokens
- ❌ More complex UX
- ❌ Higher barrier to entry
Troubleshooting
Transaction Fails Due to Gas
If transaction fails due to gas:
- Check gas limits in Dashboard
- Increase gas limit if needed
- Check daily limit hasn't been reached
High Gas Costs
If gas costs are high:
- Review transaction types
- Optimize smart contract calls
- Consider using lower-cost chains
Next Steps
- Transactions - Understand transaction handling
- Account Management - Manage user accounts