Skip to content

Commit 31fb806

Browse files
cleanup
1 parent 974349c commit 31fb806

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

apps/portal/src/app/engine/v3/guides/session-keys/page.mdx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,35 @@ const sessionKeyAccountAddress = "0x..."; // Replace with your session key addre
3737
const targetAddress = "0x..."; // Replace with your target address
3838
```
3939

40-
## Step 1: Create a Personal Account
40+
## Step 1: Configure User Smart Wallet with Session Key
4141

42-
Generate a personal account that will be used to create the smart wallet:
42+
The first step is to add our session key address as a signer to the user's smart account. This can be done by configuring the smart wallet with the session key address and permissions.
4343

44-
```typescript
45-
const personalAccount = await generateAccount({
46-
client: client,
47-
});
44+
In a React application, this can be done by using the `ConnectButton` or `ConnectEmbed` component. This will automatically configure the smart wallet with the session key address and permissions.
4845

49-
console.log("Personal account created:", personalAccount.address);
46+
```typescript
47+
<ConnectButton
48+
accountAbstraction={{
49+
chain: sepolia,
50+
sessionKey: {
51+
address: sessionKeyAccountAddress,
52+
},
53+
sponsorGas: true,
54+
}}
55+
/>
5056
```
5157

52-
## Step 2: Configure Smart Wallet with Session Key
58+
This can also be done in pure TypeScript by using the `smartWallet` function and connecting it to a personal account.
5359

54-
Create a smart wallet configuration with session key permissions:
60+
For this guide, we'll generate a random personal account that will be used to create the smart wallet:
5561

5662
```typescript
63+
// this would be the user's personal account
64+
const personalAccount = await generateAccount({
65+
client: client,
66+
});
67+
68+
// wrapped in a smart wallet with session key permissions
5769
const smart = smartWallet({
5870
chain: sepolia,
5971
sessionKey: {
@@ -65,6 +77,8 @@ const smart = smartWallet({
6577
},
6678
sponsorGas: true, // Enable gas sponsorship
6779
});
80+
81+
console.log("Personal account created:", personalAccount.address);
6882
```
6983

7084
### Session Key Permissions
@@ -75,7 +89,7 @@ The `permissions` object allows you to control what the session key can do:
7589
- Use `"*"` for all targets
7690
- Use an array of addresses for specific contracts: `["0x123...", "0x456..."]`
7791

78-
## Step 3: Connect Smart Account
92+
## Step 2: Connect Smart Account
7993

8094
Connect the smart wallet using the personal account:
8195

@@ -88,7 +102,9 @@ const smartAccount = await smart.connect({
88102
console.log("Smart account address:", smartAccount.address);
89103
```
90104

91-
## Step 4: Verify Session Key Registration
105+
Note that in a React application, this would be done automatically by the `ConnectButton` or `ConnectEmbed` component.
106+
107+
## Step 3 (Optional): Verify Session Key Registration
92108

93109
Check that the session key is properly registered as an active signer:
94110

@@ -110,7 +126,7 @@ console.log("Session key is active:", isSessionKeyActive);
110126
console.log("All active signers:", signers.map((s) => s.signer));
111127
```
112128

113-
## Step 5: Create Engine Server Wallet
129+
## Step 4: Create Engine Server Wallet
114130

115131
Set up an Engine server wallet using the session key for transaction execution:
116132

@@ -136,7 +152,7 @@ const serverWallet = Engine.serverWallet({
136152
- `smartAccountAddress`: The smart account address that will execute transactions
137153
- `type`: The account abstraction type (ERC4337)
138154

139-
## Step 6: Execute Transactions
155+
## Step 5: Execute Transactions
140156

141157
Now you can execute transactions using the session key:
142158

@@ -179,7 +195,7 @@ async function executeTransactionWithSessionKey() {
179195
});
180196

181197
const sessionKeyAccountAddress = "0x..."; // Your session key address
182-
const targetAddress = "0x..."; // Target address for transaction
198+
const targetAddress = "0x..."; // Target address for the final transaction
183199

184200
try {
185201
// Step 1: Create personal account

apps/portal/src/app/engine/v3/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
BookOpenIcon,
23
BracesIcon,
34
CloudIcon,
45
CodeIcon,
@@ -9,7 +10,6 @@ import {
910
ShieldQuestionIcon,
1011
WalletIcon,
1112
WrenchIcon,
12-
BookOpenIcon,
1313
} from "lucide-react";
1414
import type { SideBar } from "@/components/Layouts/DocLayout";
1515

0 commit comments

Comments
 (0)