Skip to content

Commit 7c87ebd

Browse files
committed
chore(docs): erc20 docs feedback
1 parent 86c1520 commit 7c87ebd

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

docs-site

docs/pages/transactions/pay-gas-with-any-token/api-postop.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for full descriptions of the parameters used in the following example.
1616
"method": "wallet_requestAccount",
1717
"params": [
1818
{
19-
"signerAddress": "'$SIGNER_ADDRESS'",
19+
"signerAddress": "'$SIGNER_ADDRESS'"
2020
}
2121
]
2222
}

docs/pages/transactions/pay-gas-with-any-token/api-preop.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"method": "wallet_requestAccount",
1313
"params": [
1414
{
15-
"signerAddress": "'$SIGNER_ADDRESS'",
15+
"signerAddress": "'$SIGNER_ADDRESS'"
1616
}
1717
]
1818
}

docs/pages/transactions/pay-gas-with-any-token/client.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const { preparedCallIds } = await client.sendCalls({
3838

3939
```ts twoslash title="client.ts"
4040
import "dotenv/config";
41-
import { Address, Hex, toHex } from "viem";
41+
import { type Address, type Hex, toHex } from "viem";
4242
import { LocalAccountSigner } from "@aa-sdk/core";
4343
import { alchemy, sepolia } from "@account-kit/infra";
4444
import { createSmartWalletClient } from "@account-kit/wallet-client";

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
22
title: Pay gas with any token
33
description: Enable users to pay gas with ERC-20 tokens like USDC
4-
slug: wallets/transactions/sponsor-gas/pay-gas-with-any-token/overview
4+
slug: wallets/transactions/pay-gas-with-any-token
55
---
66

77
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.
99

1010
## How it works
1111

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

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

1617
## Prerequisites
1718

1819
- 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).
2020
- [A "pay gas with any token" policy](https://dashboard.alchemy.com/gas-manager/policy/create).
2121

2222
## Implementation
@@ -40,14 +40,17 @@ We recommend using "post-operation" mode for most use cases. This mode requires
4040
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.
4141

4242
<Tabs>
43-
<Tab title="React">TODO - add link to `usePrepareCalls`</Tab>
43+
<Tab title="React">
44+
See the [`usePrepareCalls` react
45+
hook](/wallets/reference/account-kit/react/hooks/usePrepareCalls)
46+
</Tab>
4447
<Tab title="Javascript">
4548
See the [`prepareCalls` SDK
46-
reference](/docs/wallets/reference/account-kit/wallet-client/functions/prepareCalls)
49+
reference](/wallets/reference/account-kit/wallet-client/functions/prepareCalls)
4750
</Tab>
4851
<Tab title="API">
4952
See the [`wallet_prepareCalls` API
50-
reference](/docs/wallets/api/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls)
53+
reference](/wallets/api/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls)
5154
</Tab>
5255
</Tabs>
5356

@@ -58,7 +61,7 @@ The configured mode determines when the user's token payment occurs.
5861

5962
**[Recommended] Post-Operation**
6063

61-
- No upfront allowance is required
64+
- No upfront allowance is required.
6265
- The user signs an approval inside the same calls batch, and the paymaster pulls the token after the operation has executed.
6366
- If that post-operation transfer fails, the entire batch is reverted and you (the developer) pay the gas fee.
6467

@@ -68,15 +71,15 @@ The configured mode determines when the user's token payment occurs.
6871
- 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.
6972
- If the required allowance isn't in place when the user operation is submitted, it will be rejected.
7073

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

7376
- Is the most gas efficient as it only requires a single transfer.
7477
- Works with all ERC-20 tokens.
7578
- Only ever requires a single signature from the user.
7679

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

8184
Examples of static amounts:
8285

@@ -163,7 +166,7 @@ approval, the following steps inject the permit:
163166

164167
Build more:
165168

166-
- [Sponsor gas for users](/docs/wallets/transactions/sponsor-gas/sponsor-gas)
169+
- [Sponsor gas for users](/wallets/transactions/sponsor-gas)
167170

168171
Troubleshooting:
169172

docs/pages/transactions/pay-gas-with-any-token/react.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<Info>Required SDK version: ^v4.61.0</Info>
22

33
Use the `useSendCalls` hook and the `paymasterService` capability parameter to send calls with
4-
an ERC20 token paymaster. You can also use the `usePrepareCalls` hook to only prepare the operation for signing.
4+
an ERC20 token paymaster.
5+
6+
**Prerequisites**
7+
8+
- [Smart Wallets installed and configured in your project](/docs/wallets/pages/react/setup.mdx).
59

610
<CodeBlocks>
711

812
```ts twoslash title="sendCalls.tsx" focus={5-7,14-27}
913
import { useSendCalls, useSmartAccountClient } from "@account-kit/react";
10-
import { config } from "@/app/components/config";
14+
import { config } from "./config";
1115

1216
export default function SendCalls() {
1317
const { client } = useSmartAccountClient({});
@@ -58,7 +62,7 @@ export default function SendCalls() {
5862
```
5963

6064
```ts twoslash title="config.ts"
61-
import { Address, toHex } from "viem";
65+
import { type Address, toHex } from "viem";
6266

6367
export const config = {
6468
policyId: process.env.ALCHEMY_POLICY_ID!,

0 commit comments

Comments
 (0)