Skip to content
Open
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
16 changes: 8 additions & 8 deletions docs/base-account/improve-ux/spend-permissions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const sdk = createBaseAccountSDK({

const spender = "0xAppSpenderAddress";

// 1) Fetch a specific permission by its hash
// 1. Fetch a specific permission by its hash
// Use fetchPermission when you already know the permission hash
// (e.g., stored from a previous session or passed as a parameter)
const permission = await fetchPermission({
Expand All @@ -230,7 +230,7 @@ const permission = await fetchPermission({
// When there IS an existing permission
// ========================================

// 2. check the status of permission
// 2. Check the status of permission
try {
const { isActive, remainingSpend } = await getPermissionStatus(permission);
const amount = 1000n;
Expand All @@ -242,13 +242,13 @@ try {
throw new Error("No spend permission available");
}

// 3. prepare the calls
// 3. Prepare the calls
const [approveCall, spendCall] = await prepareSpendCallData({
permission,
amount,
});

// 4. execute the calls using your app's spender account
// 4. Execute the calls using your app's spender account
// this is an example using wallet_sendCalls, in production it could be using eth_sendTransaction.
await provider.request({
method: "wallet_sendCalls",
Expand All @@ -266,7 +266,7 @@ await provider.request({
// When there is NOT an existing permission
// ========================================

// 2. request a spend permission to use
// 2. Request a spend permission to use
const newPermission = await requestSpendPermission({
account: "0xUserBaseAccountAddress",
spender,
Expand All @@ -277,13 +277,13 @@ const newPermission = await requestSpendPermission({
provider: sdk.getProvider(),
});

// 3. prepare the calls
// 3. Prepare the calls
const spendCalls = await prepareSpendCallData({
permission: newPermission,
amount: 1_000n,
});

// 4. execute the calls using your app's spender account
// 4. Execute the calls using your app's spender account
// this is an example using eth_sendTransaction. If your app account supports wallet_sendCalls, use wallet_sendCalls to batch the calls instead.
await Promise.all(
spendCalls.map((call) =>
Expand Down Expand Up @@ -360,4 +360,4 @@ This example demonstrates how to combine Base Account's [Spend Permissions](/bas
</Card>
</CardGroup>

**Learn more:** [AI Agent with Spend Permissions](/cookbook/spend-permissions-ai-agent)
**Learn more:** [AI Agent with Spend Permissions](/cookbook/spend-permissions-ai-agent)