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
Gas fees paid in the native token can feel foreign to users that primarily hold stablecoins or your app's own token.
8
-
With smart wallets, you can allow users to pay for gas with any ERC-20 token, streamlining the user experience.
8
+
With Smart Wallets, you can allow users to pay for gas with any ERC-20 token, streamlining the user experience.
9
9
10
10
## How it works
11
11
12
-
When a user pays for gas with an ERC-20 token, the gas is fronted using the network's native gas token and the ERC-20 tokens are transferred from the user's wallet to a wallet you configure in the policy. The equivalent USD amount and the admin fee are then added to your monthly invoice.
12
+
When a user pays for gas with an ERC-20 token, the gas is fronted using the network's native gas token and the ERC-20 tokens are transferred from the user's wallet to a wallet you configure in the policy.
13
+
The equivalent USD amount and the admin fee are then added to the developer's monthly invoice.
13
14
14
-
We recommend using "post-operation" mode for most use cases. 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 ERC-20 payment. If this doesn't work for your use case, see the [ERC-20 gas payment modes](#erc-20-gas-payment-modes) section below for more options.
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 ERC-20 payment. If this doesn't work for your use case, see the [ERC-20 gas payment modes](#erc-20-gas-payment-modes) section below for more options.
15
16
16
17
## Prerequisites
17
18
18
19
- API key from your [dashboard](https://dashboard.alchemy.com/apps)
19
-
-[Smart Wallets installed and configured in your project](/docs/wallets/pages/react/setup.mdx).
20
20
-[A "pay gas with any token" policy](https://dashboard.alchemy.com/gas-manager/policy/create).
21
21
22
22
## Implementation
@@ -40,14 +40,17 @@ We recommend using "post-operation" mode for most use cases. This mode requires
40
40
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.
41
41
42
42
<Tabs>
43
-
<Tabtitle="React">TODO - add link to `usePrepareCalls`</Tab>
@@ -58,7 +61,7 @@ The configured mode determines when the user's token payment occurs.
58
61
59
62
**[Recommended] Post-Operation**
60
63
61
-
- No upfront allowance is required
64
+
- No upfront allowance is required.
62
65
- The user signs an approval inside the same calls batch, and the paymaster pulls the token after the operation has executed.
63
66
- If that post-operation transfer fails, the entire batch is reverted and you (the developer) pay the gas fee.
64
67
@@ -68,15 +71,15 @@ The configured mode determines when the user's token payment occurs.
68
71
- 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.
69
72
- If the required allowance isn't in place when the user operation is submitted, it will be rejected.
70
73
71
-
We recommend using post-operation mode for most use cases. This mode:
74
+
Post-operation mode is recommended for most use cases. This mode:
72
75
73
76
- Is the most gas efficient as it only requires a single transfer.
74
77
- Works with all ERC-20 tokens.
75
78
- Only ever requires a single signature from the user.
76
79
77
-
However, because tokens are deducted after execution, you may be required to pay for gas without receiving sufficient ERC-20 payment.
78
-
Ensure that users have enough token left over to pay for gas after the operation, otherwise you won't receive payment from users for gas and the operation will revert.
79
-
If the operation results in a static amount of the user’s ERC-20 token balance after execution and you can account for this before submitting the operation, use PostOp mode.
80
+
However, because tokens are deducted after execution, the developer may be required to pay for gas without receiving sufficient ERC-20 payment.
81
+
The developer should 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.
82
+
If the operation results in a static amount of the user’s ERC-20 token balance after execution and the developer can account for this before submitting the operation, use PostOp mode.
80
83
81
84
Examples of static amounts:
82
85
@@ -163,7 +166,7 @@ approval, the following steps inject the permit:
163
166
164
167
Build more:
165
168
166
-
-[Sponsor gas for users](/docs/wallets/transactions/sponsor-gas/sponsor-gas)
169
+
-[Sponsor gas for users](/wallets/transactions/sponsor-gas)
0 commit comments