Gas Stations
Gas stations are a powerful resource that allows you to subsidize transaction fees for your users. This means your users can interact with your dApp without needing to hold APT tokens for gas fees, making the user experience much smoother.
How It Works
A gas station acts as a fee payer for transactions on the Aptos blockchain. When properly configured:
- Your users submit transactions to your dApp
- The gas station automatically pays the gas fees
- Your users don’t need to hold APT tokens
- You maintain control over which transactions can be subsidized
Creating a Gas Station
To create a gas station:
- Navigate to your project page
- Add a “Gas Station” resource
- Provide a name and select a network
- Configure the initial contract rules (optional)
Each gas station requires an API key for authentication. One will be automatically created for you when you create the gas station.
Contract Rules
Contract rules define which transactions can be subsidized by your gas station. For each contract, you can:
- Specify which functions can be called
- Set spending limits per function
- Enable reCAPTCHA protection
- Configure rate limits
Always carefully review and test your contract rules before deploying to production. Incorrect rules could lead to unexpected gas costs.
Security Features
Gas stations include several security features to protect your resources:
- Function-level Control: Only allow specific functions to be called
- Spending Limits: Set maximum gas costs per function
- Rate Limiting: Prevent abuse through request throttling
- reCAPTCHA: Optional protection against automated attacks
- API Key Authentication: Secure access to your gas station
Limitations
- Gas stations can only subsidize transactions on the specified network
- Each function call must be explicitly allowed in the contract rules
- There are rate limits and spending limits to prevent abuse
- Some complex transactions may not be supported
API Integration
To use a gas station in your dApp:
- Get your gas station’s API key
- Configure your dApp to use the gas station’s endpoint
- Include the API key in your requests
- The gas station will automatically handle fee payment
Learn more about API keys and authentication here.
Billing
Gas stations are billed based on the actual gas costs of the transactions they subsidize. You can:
- Monitor usage in real-time
- Set up alerts for high usage
- View detailed billing reports
- Configure spending limits
Learn more about billing and costs here.