-
Notifications
You must be signed in to change notification settings - Fork 10
docs: add conditional sponsorship rules guide under sponsor gas #1013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
avarobinson
merged 5 commits into
main
from
codex/create-documentation-for-sponsorship-rules
Feb 12, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bcb2221
docs: add conditional sponsorship rules guide under sponsor gas (#1012).
avarobinson a782628
docs: Update fern/wallets/pages/transactions/sponsor-gas/conditional-…
avarobinson 7c46f4d
docs: Update fern/wallets/pages/transactions/sponsor-gas/conditional-…
avarobinson 564c29e
docs: Update fern/wallets/pages/transactions/sponsor-gas/conditional-…
avarobinson 8e1d15b
docs: Apply suggestions from code review
avarobinson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
fern/wallets/pages/transactions/sponsor-gas/conditional-sponsorship-rules.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,120 @@ | ||||
| --- | ||||
| title: Conditional sponsorship rules | ||||
| description: Control gas sponsorship with spend limits and custom rules | ||||
| slug: wallets/transactions/sponsor-gas/conditional-sponsorship-rules | ||||
| --- | ||||
|
|
||||
| Conditional sponsorship gives you precise control over what transactions get sponsored. | ||||
|
|
||||
| Use it to: | ||||
|
|
||||
| * Protect your budget with hard spending limit | ||||
| * Prioritize high-value users and actions | ||||
| * Prevent abuse with allowlists, blocklists, and custom logic | ||||
|
|
||||
| ## Ways to configure sponsorship rules | ||||
|
|
||||
| You can configure the same policy logic in two ways: | ||||
|
|
||||
| 1. **Dashboard**: Create or edit a Gas Manager policy in the [Alchemy dashboard](https://dashboard.alchemy.com/gas-manager/policy/create) | ||||
| 2. **Admin API**: Create or update policies programmatically with the [Gas Manager Admin API](/wallets/api-reference/gas-manager-admin-api/gas-manager-admin-api-endpoints/gas-manager-admin-api-endpoints) | ||||
|
|
||||
| Most teams start in the dashboard, then move to API-based management for automation. | ||||
|
|
||||
| ## Built-in policy limits | ||||
|
|
||||
| Use built-in limits when you want fast setup without maintaining backend logic. | ||||
|
|
||||
| You can combine these controls in one policy: | ||||
|
|
||||
| * **Time-bounded policies**: Only sponsor during a specific start/end window | ||||
| * **Per-user spend limits**: Cap sponsorship spend per wallet/user | ||||
| * **Per-transaction spend limits**: Cap sponsorship per transaction | ||||
| * **Global max spend**: Set a hard maximum spend for the full policy | ||||
| * **Max transactions per user**: Limit number of sponsored transactions per user | ||||
| * **Sender allowlist / blocklist**: Explicitly allow or deny sponsorship for selected senders | ||||
|
|
||||
| These limits are ideal for growth campaigns, onboarding credits, and controlled rollouts. | ||||
|
|
||||
| ## Custom rules with webhooks | ||||
|
|
||||
| For advanced use cases, add a webhook so your server can approve or reject sponsorship requests in real time. | ||||
|
|
||||
| Examples: | ||||
|
|
||||
| * Sponsor only swaps | ||||
| * Sponsor only transactions that touch your contracts | ||||
| * Sponsor only high-ROI users (for example, power users) | ||||
| * Sponsor users with proof-of-humanity checks | ||||
|
|
||||
| ### How webhook-based sponsorship works | ||||
|
|
||||
| When a sponsorship request is made, Gas Manager sends a `POST` request to your webhook. | ||||
|
|
||||
| Your server evaluates the request and returns whether to approve sponsorship. | ||||
|
|
||||
| #### Request payload | ||||
|
|
||||
| ```json | ||||
| { | ||||
| "userOperation": {}, | ||||
| "policyId": "", | ||||
| "chainId": "", | ||||
| "webhookData": "" | ||||
| } | ||||
| ``` | ||||
|
|
||||
| Payload fields: | ||||
|
|
||||
| * `userOperation`: UserOperation payload (shape depends on EntryPoint version) | ||||
| * `policyId`: Policy ID receiving the sponsorship request | ||||
| * `chainId`: Chain ID for the request | ||||
| * `webhookData` (optional): Additional app data, such as user attestations | ||||
|
|
||||
| #### Expected webhook response | ||||
|
|
||||
| Return HTTP `200` and: | ||||
|
|
||||
| ```json | ||||
| { | ||||
| "approved": true | ||||
| } | ||||
| ``` | ||||
|
|
||||
| Set `approved` to: | ||||
|
|
||||
| * `true` to sponsor gas | ||||
| * `false` to reject sponsorship | ||||
|
|
||||
| ### Configure webhook rules on your policy | ||||
|
|
||||
| In your policy's **Custom Rules** section, set: | ||||
|
|
||||
| * `webhookUrl` (required): Endpoint Gas Manager calls for eligibility | ||||
| * `approveOnFailure` (required, default `false`): If `true`, sponsorship is approved when webhook errors or times out | ||||
|
|
||||
| In the Admin API, this configuration is represented as: | ||||
|
|
||||
| ```json | ||||
| { | ||||
| "webhookRules": { | ||||
| "webhookUrl": "https://your-server.com/sponsor-gas", | ||||
| "approveOnFailure": false | ||||
| } | ||||
| } | ||||
| ``` | ||||
|
|
||||
| ## Recommended setup pattern | ||||
|
|
||||
| For most teams, the best approach is: | ||||
|
|
||||
| 1. Start with built-in limits for immediate spend protection | ||||
| 2. Add webhook rules for business-specific checks | ||||
| 3. Decide your failure mode (`approveOnFailure`) based on risk tolerance: | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| * Prefer uptime: set to `true` | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| * Prefer strict control: set to `false` | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
|
||||
| ## Next steps | ||||
|
|
||||
| * [Full sponsorship implementation](/wallets/transactions/sponsor-gas) | ||||
| * [Gas Manager Admin API endpoints](/wallets/api-reference/gas-manager-admin-api/gas-manager-admin-api-endpoints/gas-manager-admin-api-endpoints) | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.