Skip to content

Commit

Permalink
Add initial smart wallets guide (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-maj authored Sep 29, 2023
1 parent 1ecbc2b commit 76a770c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ yarn dev:infra

## User Guide

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

## API Documentation

Expand Down
File renamed without changes.
53 changes: 53 additions & 0 deletions docs/2-smart-wallets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Smart Wallets

You can use engine to deploy, manage, and transact with smart wallets on behalf of your users.

Make sure to read the `README.md` and previous `user-guide.md` before starting this one.

### 1. Deploy an account factory

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.

**Endpoint:** `POST - /deploy/{chain}/deployer.thirdweb.eth/AccountFactory`

**Payload:**

```json
{
"constructorParams": ["0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"]
}
```

### 2. Deploy accounts for your users

Once you have a factory setup, you can use it to deploy accounts for your users.

**Endpoint:** `POST - /contract/{chain}/{account_factory_address}/account-factory/create-account`

```json
{
"admin_address": "0x..." // The user wallet address that you want to deploy a smart wallet for
}
```

This will add the `admin_address` as the primary admin that can act on behalf of the newly deployed account.

If you want to control the account with one of your backend wallets, you can specify the backend wallet in the `admin_address` field.

### 3. Grant permissions and sessions

You can manage the permissions of who has control over a smart wallet.

You can grant & revoke admins on your account with the `/contract/{chain}/{account_address}/account/admins` endpoints.

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.

### 4. Transact with an account

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.

The `x-backend-wallet-address` should be set to the engine backend wallet that is an admin over the account.

The `x-account-address` should be set to the deployed account address itself.

Write calls made using these headers will initiate a `UserOperation` sent from the specified account.
File renamed without changes.

0 comments on commit 76a770c

Please sign in to comment.