Skip to content

Commit 3ab63aa

Browse files
feat: auto spend permissions docs (#258)
* feat: spend permissions docs * copy changes * add configuration steps --------- Co-authored-by: Montana Wong <[email protected]>
1 parent 09f147d commit 3ab63aa

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

docs/base-account/improve-ux/spend-permissions.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Read more about the Spend Permission Manager contract and supported chains on [G
1515
Spend Permissions for Base App Mini Apps are coming soon and will be supported in a future update.
1616
</Callout>
1717

18+
<Note>
19+
If you're using Sub Accounts, learn how Base Account can automatically fund Sub Accounts and optionally skip approval prompts using [Auto Spend Permissions](/base-account/improve-ux/sub-accounts#auto-spend-permissions).
20+
</Note>
21+
1822
## Usage
1923

2024
### Request a Spend Permission

docs/base-account/improve-ux/sub-accounts.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,49 @@ const ownerAccount = await sdk.subAccount.addOwner({
260260
console.log('Owner added to Sub Account');
261261
```
262262

263+
## Auto Spend Permissions
264+
265+
Auto Spend Permissions allows Sub Accounts to access funds from their parent Base Account when transaction balances are insufficient. This feature can also establish ongoing spend permissions, enabling future transactions to execute without user approval prompts, reducing friction in your app's transaction flow.
266+
267+
### Configuration
268+
269+
Auto Spend Permissions is only available in SDK version `2.0.2-canary.20250822164845` or later. This feature is **enabled by default** when using Sub Accounts.
270+
271+
To disable Auto Spend Permissions when using Sub Accounts, set `unstable_enableAutoSpendPermissions` to `false` in your SDK configuration:
272+
273+
```tsx
274+
const sdk = createBaseAccountSDK({
275+
appName: 'Base Account SDK Demo',
276+
appLogoUrl: 'https://base.org/logo.png',
277+
appChainIds: [base.id],
278+
subAccounts: {
279+
unstable_enableAutoSpendPermissions: false, // Disable auto spend permissions
280+
}
281+
});
282+
```
283+
284+
### How it works
285+
286+
**First-time transaction flow:**
287+
When a Sub Account attempts its first transaction, Base Account displays a popup for user approval. During this approval process, Base Account:
288+
289+
- Automatically detects any missing tokens (native or ERC-20) needed for the transaction
290+
- Requests a transfer of the required funds from the parent Base Account to the Sub Account to fulfill the current transaction
291+
- Allows the user to optionally grant ongoing spend permissions for future transactions in that token
292+
293+
**Subsequent transactions:**
294+
If the user granted spend permissions, future transactions follow this priority:
295+
296+
1. First, attempt using existing Sub Account balances and granted spend permissions
297+
2. If insufficient, prompt the user to authorize additional transfers and/or spend permissions from their Base Account
298+
299+
<Warning>
300+
Spend permission requests are limited to the first token when multiple transfers are needed for a single transaction. Additional tokens require separate approvals.
301+
</Warning>
302+
303+
304+
305+
263306
## Complete Integration Example
264307

265308
Here's a full React component that demonstrates Sub Account creation and usage:

docs/base-account/reference/core/createBaseAccount.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Where `OwnerAccount` is a union type of:
7272
- `WebAuthnAccount` (from viem) - A WebAuthn-based account for passkey authentication
7373
</Expandable>
7474
</ParamField>
75+
<ParamField body="unstable_enableAutoSpendPermissions" type="boolean">
76+
When <code>true</code> (default), enables Auto Spend Permissions for sub-accounts. This allows automatic transfers from the user's Base Account to the sub-account when funds are missing and attempts background transactions using existing spend permissions. Set to <code>false</code> to disable this behavior. Learn more in [Auto Spend Permissions](/base-account/improve-ux/sub-accounts#auto-spend-permissions).
77+
</ParamField>
7578
</Expandable>
7679
</ParamField>
7780

0 commit comments

Comments
 (0)