Skip to content

Commit 4ab4c8b

Browse files
Merge "Create a smart account" page and other fixes (#2208)
* Merge "Create a smart account" page and other fixes * address reviewer feedback
1 parent 52e10dc commit 4ab4c8b

File tree

14 files changed

+123
-166
lines changed

14 files changed

+123
-166
lines changed

delegation-toolkit/concepts/smart-accounts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ ERC-4337 introduces the following concepts:
3939

4040
The MetaMask Delegation Toolkit supports three types of MetaMask Smart Accounts, each offering unique features and use cases.
4141

42-
See [Configure accounts and signers](../how-to/create-smart-account/configure-accounts-signers.md) to learn how to use these different account types.
42+
See [Create a smart account](../how-to/create-smart-account.md) to learn how to use these different account types.
4343

4444
### Hybrid smart account
4545

46-
The Hybrid smart account is a flexible implementation that supports both an externally owned account (EOA) "owner" and any number of P256 (passkey) signers.
46+
The Hybrid smart account is a flexible implementation that supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers.
4747
You can configure any of these signers as the signatory, and use them to sign any data, including user operations, on behalf of the smart account.
4848

4949
This type is referenced in the toolkit as `Implementation.Hybrid`.

delegation-toolkit/experimental/erc-7710-redeem-delegations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Redeem a delegation with a [MetaMask smart account](#redeem-with-a-metamask-smar
8484

8585
### Redeem with a MetaMask smart account
8686

87-
To redeem a delegation with a MetaMask smart account, create a [`MetaMaskSmartAccount`](../how-to/create-smart-account/index.md#create-a-metamasksmartaccount)
87+
To redeem a delegation with a MetaMask smart account, [create a smart account](../how-to/create-smart-account.md)
8888
and a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler).
8989

9090
After setting up your Bundler Client, you can extend its functionality with `erc7710BundlerActions` actions to support ERC-7710. Once extended, use [`sendUserOperationWithDelegation`](../reference/api/experimental-actions/bundler-client.md#senduseroperationwithdelegation) to redeem the permission.

delegation-toolkit/experimental/store-retrieve-delegations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
description: Store and retrieve delegations using the `DelegationStorageClient`.
33
sidebar_position: 1
44
toc_max_heading_level: 2
5+
sidebar_class_name: hidden
56
---
67

78
import Tabs from "@theme/Tabs";

delegation-toolkit/get-started/delegation-quickstart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ const bundlerClient = createBundlerClient({
4848
### 3. Create a delegator account
4949

5050
Create an account to represent Alice, the delegator who will create a delegation.
51-
The delegator must be a [smart account](../how-to/create-smart-account/index.md).
51+
The delegator must be a [MetaMask smart account](../concepts/smart-accounts.md).
5252

53-
This example configures a [Hybrid](../concepts/smart-accounts.md#hybrid-smart-account) smart account,
53+
This example configures a Hybrid smart account,
5454
which is a flexible smart account implementation that supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers:
5555

5656
```typescript
@@ -69,7 +69,7 @@ const delegatorSmartAccount = await toMetaMaskSmartAccount({
6969
```
7070

7171
:::note
72-
See [how to configure other smart account types](../how-to/create-smart-account/configure-accounts-signers.md).
72+
See [how to configure other smart account types](../how-to/create-smart-account.md).
7373
:::
7474

7575
### 4. Create a delegate account

delegation-toolkit/get-started/quickstart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const bundlerClient = createBundlerClient({
4343

4444
### 3. Create a MetaMask smart account
4545

46-
[Create a MetaMask smart account](../how-to/create-smart-account/index.md) to send the first user operation.
46+
[Create a MetaMask smart account](../how-to/create-smart-account.md) to send the first user operation.
4747

48-
This example configures a [Hybrid](../concepts/smart-accounts.md#hybrid-smart-account) smart account,
48+
This example configures a Hybrid smart account,
4949
which is a flexible smart account implementation that supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers:
5050

5151
```typescript
@@ -64,7 +64,7 @@ const smartAccount = await toMetaMaskSmartAccount({
6464
```
6565

6666
:::note
67-
See [how to configure other smart account types](../how-to/create-smart-account/configure-accounts-signers.md).
67+
See [how to configure other smart account types](../how-to/create-smart-account.md).
6868
:::
6969

7070
### 4. Send a user operation

delegation-toolkit/how-to/create-delegation/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Learn how to [restrict a delegation](./restrict-delegation.md) using caveat enfo
2828

2929
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
3030
- [Configure the Delegation Toolkit.](../configure.md)
31-
- [Create a MetaMask smart account.](../create-smart-account/index.md)
31+
- [Create a MetaMask smart account.](../create-smart-account.md)
3232

3333
## Create a root delegation
3434

Lines changed: 41 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,29 @@
11
---
2-
sidebar_label: Configure accounts and signers
3-
description: Learn how to configure different types of MetaMask Smart Accounts and signers using Viem.
4-
sidebar_position: 1
2+
description: Learn how to create a MetaMask smart account using Viem.
3+
sidebar_position: 2
54
---
65

76
import Tabs from "@theme/Tabs";
87
import TabItem from "@theme/TabItem";
98

10-
# Configure MetaMask Smart Accounts and signers
9+
# Create a MetaMask smart account
1110

12-
The MetaMask Delegation Toolkit supports different [MetaMask smart account types](../../concepts/smart-accounts.md#smart-account-implementation-types),
13-
each with its own configuration and support for different signing mechanisms.
14-
You can create flexible and secure delegator accounts tailored to your specific needs.
11+
You can enable users to create a [MetaMask smart account](../concepts/smart-accounts.md) directly in your dapp.
12+
This page provides examples of using [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) with Viem Core SDK to create different types of smart accounts with different types of signatories.
1513

1614
## Prerequisites
1715

18-
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
19-
- [Configure the Delegation Toolkit.](../configure.md)
20-
- [Create a MetaMask smart account.](index.md)
16+
- [Install and set up the Delegation Toolkit.](../get-started/install.md)
17+
- [Configure the Delegation Toolkit.](configure.md)
2118

22-
## Configure a Hybrid smart account
19+
## Create a Hybrid smart account
2320

24-
The [Hybrid smart account](../../concepts/smart-accounts.md#hybrid-smart-account) supports both an EOA "owner" and any number of P256 (passkey) signers.
21+
A Hybrid smart account supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers.
22+
You can create a Hybrid smart account with the following types of signatories.
2523

26-
To configure a Hybrid smart account, provide the following parameters:
24+
### Create a Hybrid smart account with an Account signatory
2725

28-
- `owner`: The owner's account address as a hex string.
29-
The owner can be the zero address, indicating that there is no owner configured.
30-
- `p256KeyIds`: An array of key identifiers for P256 signers as hex strings.
31-
- `p256XValues`: An array of public key x-values for P256 signers as `bigint`s.
32-
- `p256YValues`: An array of public key y-values for P256 signers as `bigint`s.
33-
- `signatory`: A signer that will sign on behalf of the smart account.
34-
35-
:::note
36-
You can set all `p256` parameters to empty arrays to configure no WebAuthn signer.
37-
However, we recommend configuring at least one signer for account recovery.
38-
:::
39-
40-
For a Hybrid smart account, you can configure the following types of signatories:
41-
42-
### Configure an account signatory
43-
44-
This example creates a signatory from a private key using Viem's [`privateKeyToAccount`](https://viem.sh/docs/accounts/local/privateKeyToAccount) function.
26+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`privateKeyToAccount`](https://viem.sh/docs/accounts/local/privateKeyToAccount) to create a Hybrid smart account with a signatory from a private key:
4527

4628
<Tabs>
4729
<TabItem value="example.ts">
@@ -92,10 +74,9 @@ export const account = privateKeyToAccount(privateKey);
9274
</TabItem>
9375
</Tabs>
9476

95-
### Configure a Wallet Client signatory
77+
### Create a Hybrid smart account with a Wallet Client signatory
9678

97-
This example creates a [Viem Wallet Client](https://viem.sh/docs/clients/wallet) as the signatory,
98-
using Viem's `createWalletClient` function.
79+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`createWalletClient`](https://viem.sh/docs/clients/wallet) to create a Hybrid smart account with a Wallet Client signatory:
9980

10081
<Tabs>
10182
<TabItem value="example.ts">
@@ -157,15 +138,12 @@ export const walletClient = createWalletClient({
157138
</TabItem>
158139
</Tabs>
159140

160-
### Configure a WebAuthn (passkey) signatory
141+
### Create a Hybrid smart account with a WebAuthn (passkey) signatory
161142

162-
This example creates a [Viem WebAuthn Account](https://viem.sh/account-abstraction/accounts/webauthn) as the signatory,
163-
using Viem's `toWebAuthnAccount` function.
143+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`toWebAuthnAccount`](https://viem.sh/account-abstraction/accounts/webauthn) to create a Hybrid smart account with a WebAuthn Account signatory:
164144

165145
:::info Installation required
166-
167146
To work with WebAuthn, install the [Ox SDK](https://oxlib.sh/).
168-
169147
:::
170148

171149
<Tabs>
@@ -231,21 +209,10 @@ export const webAuthnAccount = toWebAuthnAccount({ credential });
231209
</TabItem>
232210
</Tabs>
233211

212+
## Create a Multisig smart account
234213

235-
## Configure a Multisig smart account
236-
237-
The [Multisig smart account](../../concepts/smart-accounts.md#multisig-smart-account) supports multiple EOA signers with a configurable threshold for execution.
238-
239-
To configure a Multisig smart account, provide the following parameters:
240-
241-
- `signers`: An array of EOA signer addresses as hex strings.
242-
- `threshold`: The number of signers required to execute a transaction, as a `bigint`.
243-
- `signatory`: A signer that will sign on behalf of the smart account.
244-
245-
### Configure signatories
246-
247-
For a Multisig smart account, you can use a combination of account signatories and Wallet Client signatories.
248-
For example:
214+
A [Multisig smart account](../concepts/smart-accounts.md#multisig-smart-account) supports multiple EOA signers with a configurable threshold for execution.
215+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) to create a Multsig smart account with a combination of account signatories and Wallet Client signatories:
249216

250217
<Tabs>
251218
<TabItem value="example.ts">
@@ -316,21 +283,20 @@ export const walletClient = createWalletClient({
316283
The number of signers in the signatories must be at least equal to the threshold for valid signature generation.
317284
:::
318285

319-
## Configure a Stateless 7702 smart account
286+
## Create a Stateless 7702 smart account
320287

321-
The [Stateless 7702 smart account](../../concepts/smart-accounts.md#stateless-7702-smart-account) represents an EOA that has been upgraded to support MetaMask Smart Accounts
322-
functionality as defined by [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702). This implementation does not handle the upgrade process; see the [EIP-7702 quickstart](./../../get-started/eip7702-quickstart.md) to learn how to upgrade.
288+
A [Stateless 7702 smart account](../concepts/smart-accounts.md#stateless-7702-smart-account) represents an EOA that has been upgraded to support MetaMask Smart Accounts
289+
functionality as defined by [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702).
323290

324-
To configure a Stateless 7702 smart account, provide the following parameters:
325-
326-
- `address`: The address of the EOA that has been upgraded to a smart account.
327-
- `signatory`: A signer that will sign on behalf of the smart account.
291+
:::note
292+
This implementation does not handle the upgrade process; see the [EIP-7702 quickstart](../get-started/eip7702-quickstart.md) to learn how to upgrade.
293+
:::
328294

329-
For a Stateless 7702 smart account, you can configure the following types of signatories:
295+
You can create a Stateless 7702 smart account with the following types of signatories.
330296

331-
### Configure an account signatory
297+
### Create a Stateless 7702 smart account with an account signatory
332298

333-
This example creates a signatory from a private key using Viem's [`privateKeyToAccount`](https://viem.sh/docs/accounts/local/privateKeyToAccount) function.
299+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`privateKeyToAccount`](https://viem.sh/docs/accounts/local/privateKeyToAccount) to create a Stateless 7702 smart account with a signatory from a private key:
334300

335301
<Tabs>
336302
<TabItem value="example.ts">
@@ -346,7 +312,7 @@ import {
346312
const smartAccount = await toMetaMaskSmartAccount({
347313
client: publicClient,
348314
implementation: Implementation.Stateless7702,
349-
address: account.address
315+
address: account.address // Address of the upgraded EOA
350316
signatory: { account },
351317
});
352318
```
@@ -380,10 +346,9 @@ export const account = privateKeyToAccount(privateKey);
380346
</TabItem>
381347
</Tabs>
382348

383-
### Configure a Wallet Client signatory
349+
### Create a Stateless 7702 smart account with a Wallet Client signatory
384350

385-
This example creates a [Viem Wallet Client](https://viem.sh/docs/clients/wallet) as the signatory,
386-
using Viem's `createWalletClient` function.
351+
Use [`toMetaMaskSmartAccount`](../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`createWalletClient`](https://viem.sh/docs/clients/wallet) to create a Stateless 7702 smart account with a Wallet Client signatory:
387352

388353
<Tabs>
389354
<TabItem value="example.ts">
@@ -402,7 +367,7 @@ const address = addresses[0];
402367
const smartAccount = await toMetaMaskSmartAccount({
403368
client: publicClient,
404369
implementation: Implementation.Stateless7702,
405-
address,
370+
address, // Address of the upgraded EOA
406371
signatory: { walletClient },
407372
});
408373
```
@@ -443,3 +408,12 @@ export const walletClient = createWalletClient({
443408

444409
</TabItem>
445410
</Tabs>
411+
412+
## Next steps
413+
414+
With a MetaMask smart account, you can perform the following functions:
415+
416+
- In conjunction with [Viem Account Abstraction clients](configure.md), deploy the smart account
417+
and [send user operations](send-user-operation.md).
418+
- [Create delegations](create-delegation/index.md) that can be used to grant specific rights and permissions to other accounts.
419+
Smart accounts that create delegations are called *delegator accounts*.

delegation-toolkit/how-to/create-smart-account/index.md

Lines changed: 0 additions & 82 deletions
This file was deleted.

delegation-toolkit/how-to/generate-multisig-signature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ into a single aggregated signature.
1919

2020
- [Install and set up the Delegation Toolkit.](../get-started/install.md)
2121
- [Configure the Delegation Toolkit.](configure.md)
22-
- [Create a Multisig smart account.](create-smart-account/configure-accounts-signers.md#configure-a-multisig-smart-account)
22+
- [Create a Multisig smart account.](create-smart-account.md#create-a-multisig-smart-account)
2323

2424
## Generate a multisig signature
2525

delegation-toolkit/how-to/redeem-delegation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The function supports batch redemption, allowing multiple delegations to be proc
2020

2121
- [Install and set up the Delegation Toolkit.](../get-started/install.md)
2222
- [Configure the Delegation Toolkit.](configure.md)
23-
- [Create a delegator smart account.](create-smart-account/index.md)
23+
- [Create a delegator smart account.](create-smart-account.md)
2424
- [Create a delegation.](create-delegation/index.md)
2525

2626
## Redeem a delegation

0 commit comments

Comments
 (0)