Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions content/wallets/pages/transactions/pay-gas-with-any-token/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,38 @@ Post-operation mode is recommended for most use cases. If the token approval is

## Advanced

### Token gas payment modes

The configured mode determines when the user’s token payment occurs.

**\[Recommended] Post-Operation**

* No upfront allowance is required.
* If the paymaster does not already have a sufficient allowance, a token approval is injected into the same atomic calls batch as your operations. The paymaster contract pulls the token after execution.
* When an approval is injected into the 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.
* If a sufficient allowance already exists (e.g., from threshold mode or a prior approval), no approval is injected and the paymaster can collect payment even if the batch reverts.

**Pre-Operation:**

* The paymaster contract must have an allowance prior to the operation.
* 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.
* Because the token transfer occurs during validation (before execution), the paymaster collects payment regardless of whether the operation reverts.
* If the required allowance isn’t in place when the transaction is submitted, it will be rejected.

**Choosing a mode:**

Use **post-operation** mode when your operations are unlikely to revert. This mode:

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

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:

* Swaps or other operations with dynamic outcomes
* Any operation where revert conditions are difficult to predict ahead of time
* High-value gas operations where uncompensated gas costs are unacceptable

<Accordion title="Usage with prepare calls">
Pay gas with any token also works with the prepare calls methods in the various frameworks. Usage of the capability will be the same as when using send calls. It is recommended to use prepare calls if you want to inspect the prepared call prior to prompting the user for signature.

Expand All @@ -50,38 +82,6 @@ Post-operation mode is recommended for most use cases. If the token approval is
</Tabs>
</Accordion>

<Accordion title="Token gas payment modes">
The configured mode determines when the user’s token payment occurs.

**\[Recommended] Post-Operation**

* No upfront allowance is required.
* If the paymaster does not already have a sufficient allowance, a token approval is injected into the same atomic calls batch as your operations. The paymaster contract pulls the token after execution.
* When an approval is injected into the 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.
* If a sufficient allowance already exists (e.g., from threshold mode or a prior approval), no approval is injected and the paymaster can collect payment even if the batch reverts.

**Pre-Operation:**

* The paymaster contract must have an allowance prior to the operation.
* 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.
* Because the token transfer occurs during validation (before execution), the paymaster collects payment regardless of whether the operation reverts.
* If the required allowance isn’t in place when the transaction is submitted, it will be rejected.

**Choosing a mode:**

Use **post-operation** mode when your operations are unlikely to revert. This mode:

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

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:

* Swaps or other operations with dynamic outcomes
* Any operation where revert conditions are difficult to predict ahead of time
* High-value gas operations where uncompensated gas costs are unacceptable
</Accordion>

<Accordion title="Pre-operation mode implementation">
<Markdown src="api-preop.mdx" />
</Accordion>
Expand Down
Loading