Skip to content

Commit 76a770c

Browse files
authored
Add initial smart wallets guide (#178)
1 parent 1ecbc2b commit 76a770c

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ yarn dev:infra
140140

141141
## User Guide
142142

143-
View all end-points details (Open API Specification) : [User Guide](./docs/UserGuide.md)
143+
View all end-points details (Open API Specification) : [User Guide](./docs/1-user-guide.md)
144144

145145
## API Documentation
146146

File renamed without changes.

docs/2-smart-wallets.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Smart Wallets
2+
3+
You can use engine to deploy, manage, and transact with smart wallets on behalf of your users.
4+
5+
Make sure to read the `README.md` and previous `user-guide.md` before starting this one.
6+
7+
### 1. Deploy an account factory
8+
9+
In order to deploy smart wallet accounts (which we'll refer to as "accounts" from here on), you'll need an `AccountFactory` contract deployed. This contract handles deploying individual `Account` contracts for your users.
10+
11+
**Endpoint:** `POST - /deploy/{chain}/deployer.thirdweb.eth/AccountFactory`
12+
13+
**Payload:**
14+
15+
```json
16+
{
17+
"constructorParams": ["0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"]
18+
}
19+
```
20+
21+
### 2. Deploy accounts for your users
22+
23+
Once you have a factory setup, you can use it to deploy accounts for your users.
24+
25+
**Endpoint:** `POST - /contract/{chain}/{account_factory_address}/account-factory/create-account`
26+
27+
```json
28+
{
29+
"admin_address": "0x..." // The user wallet address that you want to deploy a smart wallet for
30+
}
31+
```
32+
33+
This will add the `admin_address` as the primary admin that can act on behalf of the newly deployed account.
34+
35+
If you want to control the account with one of your backend wallets, you can specify the backend wallet in the `admin_address` field.
36+
37+
### 3. Grant permissions and sessions
38+
39+
You can manage the permissions of who has control over a smart wallet.
40+
41+
You can grant & revoke admins on your account with the `/contract/{chain}/{account_address}/account/admins` endpoints.
42+
43+
You can grant & revoke sessions on your account which allow specific wallets to interact with specified contracts for a given period of time with the `/contract/{chain}/{account_address}/account/sessions` endpoints.
44+
45+
### 4. Transact with an account
46+
47+
You can make write calls with a smart account by calling any of the write endpoints and specifying both the `x-backend-wallet-address` and `x-account-address` headers.
48+
49+
The `x-backend-wallet-address` should be set to the engine backend wallet that is an admin over the account.
50+
51+
The `x-account-address` should be set to the deployed account address itself.
52+
53+
Write calls made using these headers will initiate a `UserOperation` sent from the specified account.
File renamed without changes.

0 commit comments

Comments
 (0)