You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Post-op token paymasters inject an approval into the same atomic call
batch. If any call reverts, the approval reverts too and the policy
owner pays gas without token compensation. Updated docs to make this
risk explicit and clarify when to use pre-op mode instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: content/wallets/pages/transactions/pay-gas-with-any-token/index.mdx
+13-19Lines changed: 13 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ With Smart Wallets, you can allow users to pay for gas with any token, streamlin
12
12
When a user pays for gas with a token, the gas is fronted using the network's native gas token and the payment tokens are transferred from the user's wallet to a wallet you configure in the policy.
13
13
The equivalent USD amount and the admin fee are then added to your monthly invoice.
14
14
15
-
Post-operation mode is recommended. This mode requires users to hold enough of the gas token in their wallet after their operation completes to pay the gas fee. If the balance is insufficient, the transaction reverts and you sponsor any gas used without token payment. If this doesn't work for your use case, see the [Token gas payment modes](#token-gas-payment-modes) section below for more options.
15
+
Post-operation mode is recommended for most use cases. If the user's balance is insufficient or any call in the batch reverts, you (the policy owner) pay the gas cost without receiving token compensation. See the [Token gas payment modes](#token-gas-payment-modes) section below for details on when to use pre-operation mode instead.
16
16
17
17
## Prerequisites
18
18
@@ -51,40 +51,34 @@ Post-operation mode is recommended. This mode requires users to hold enough of t
51
51
</Accordion>
52
52
53
53
<Accordiontitle="Token gas payment modes">
54
-
The configured mode determines when the user's token payment occurs.
54
+
The configured mode determines when the user’s token payment occurs.
55
55
56
56
**\[Recommended] Post-Operation**
57
57
58
58
* No upfront allowance is required.
59
-
* The user signs an approval inside the same calls batch, and the paymaster contract pulls the token after the operation has executed.
60
-
*If that post-operation transfer fails, the entire batchis revertedand you (the developer) pay the gas fee.
59
+
* The token approval is injected into the same atomic calls batch as your operations, and the paymaster contract pulls the token after execution.
60
+
*Because the approval and your calls are in the same atomic batch, if any call reverts, the approval is also reverted. The paymaster cannot collect the token payment and you (the policy owner) pay the gas cost without receiving token compensation.
61
61
62
62
**Pre-Operation:**
63
63
64
64
* The paymaster contract must have an allowance prior to the operation.
65
65
* This can be done either through a prior call to `approve()` or by using an [ERC-7597 Permit](https://eips.ethereum.org/EIPS/eip-7597) signature.
66
-
* If the required allowance isn't in place when the transaction is submitted, it will be rejected.
66
+
* Because the token transfer occurs during validation (before execution), the paymaster collects payment regardless of whether the operation reverts.
67
+
* If the required allowance isn’t in place when the transaction is submitted, it will be rejected.
67
68
68
-
Post-operation mode is recommended for most use cases. This mode:
69
+
**Choosing a mode:**
70
+
71
+
Use **post-operation** mode when your operations are unlikely to revert. This mode:
69
72
70
73
* Is the most gas efficient as it requires a single transfer.
71
74
* Works with all ERC-20 tokens.
72
75
* Requires a single signature from the user.
73
76
74
-
However, because tokens are deducted after execution, you may be required to pay for gas without receiving sufficient token payment.
75
-
Ensure that users have enough token left over to pay for gas after the operation, otherwise they won’t receive payment from users for gas and the operation will revert.
76
-
If the operation results in a static amount of the user’s token balance after execution and you can account for this before submitting the operation, use PostOp mode.
77
-
78
-
Examples of static amounts:
79
-
80
-
* Payments, purchases, and deposits
81
-
* Operations unrelated to the payment token
82
-
83
-
Examples of dynamic amounts:
84
-
85
-
* Swaps that include the payment token
77
+
Use **pre-operation** mode when your operations may revert. Because the token transfer happens before execution, the paymaster is always compensated regardless of the execution outcome. This is the safer choice for:
86
78
87
-
If you sponsor operations that result in dynamic amounts of the payment token left over, consider using pre-operation mode. See an example implementation below.
79
+
* Swaps or other operations with dynamic outcomes
80
+
* Any operation where revert conditions are difficult to predict ahead of time
81
+
* High-value gas operations where uncompensated gas costs are unacceptable
0 commit comments