Skip to content

Commit c0ab81c

Browse files
jakehobbsclaude
andcommitted
docs: clarify ERC20 post-op paymaster revert risk
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>
1 parent 1f7e9ba commit c0ab81c

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

  • content/wallets/pages/transactions/pay-gas-with-any-token

content/wallets/pages/transactions/pay-gas-with-any-token/index.mdx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ With Smart Wallets, you can allow users to pay for gas with any token, streamlin
1212
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.
1313
The equivalent USD amount and the admin fee are then added to your monthly invoice.
1414

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.
1616

1717
## Prerequisites
1818

@@ -51,40 +51,34 @@ Post-operation mode is recommended. This mode requires users to hold enough of t
5151
</Accordion>
5252

5353
<Accordion title="Token gas payment modes">
54-
The configured mode determines when the user's token payment occurs.
54+
The configured mode determines when the users token payment occurs.
5555

5656
**\[Recommended] Post-Operation**
5757

5858
* 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 batch is reverted and 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.
6161

6262
**Pre-Operation:**
6363

6464
* The paymaster contract must have an allowance prior to the operation.
6565
* 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.
6768

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:
6972

7073
* Is the most gas efficient as it requires a single transfer.
7174
* Works with all ERC-20 tokens.
7275
* Requires a single signature from the user.
7376

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:
8678

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
8882
</Accordion>
8983

9084
<Accordion title="Pre-operation mode implementation">

0 commit comments

Comments
 (0)