Skip to content

Commit 3915031

Browse files
authored
Merge branch 'main' into bundler
2 parents 5cd3f62 + bdf0c6c commit 3915031

File tree

181 files changed

+8734
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+8734
-237
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
# so the listed codeowners apply only if there is no later match.
33

44
# Default owner for all other files
5-
* @MetaMask/dashboard @MetaMask/tech-writers
6-
7-
# All other Markdown files
8-
*.md @MetaMask/tech-writers
9-
*.mdx @MetaMask/tech-writers
5+
* @MetaMask/dashboard @MetaMask/tech-writers @MetaMask/delegation-devrel @MetaMask/embedded-wallets-devrel @MetaMask/sdk-devrel
106

117
# Developer tools documentation
128
/developer-tools/ @MetaMask/tech-writers

delegation-toolkit/concepts/delegation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar_position: 2
66
# Delegation
77

88
*Delegation* is the ability for a [MetaMask smart account](smart-accounts.md) to grant permission to another smart account
9-
or externally owned account (EOA) to perform specific executions on their behalf, under defined rules and restrictions.
9+
or externally owned account (EOA) to perform specific executions on its behalf, under defined rules and restrictions.
1010
The account that grants the permission is called the *delegator account*, while the account that receives the permission
1111
is called the *delegate account*.
1212

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ Upon installation, you'll be asked the following prompts:
2626
❯ nextjs
2727
vite-react
2828
? Pick a template: (Use arrow keys)
29-
❯ Basic Delegator app with NextJS
30-
Experimental: Basic Gator app to try out ERC7715 Permissions
29+
❯ MetaMask Smart Accounts Starter
30+
MetaMask Smart Accounts & Delegation Starter
31+
Experimental: ERC7715 Permissions starter
3132
? Pick a package manager: (Use arrow keys)
3233
❯ npm
3334
yarn
3435
pnpm
3536
```
3637

37-
Once you've answered the prompts with the required configuration and selected a template, the CLI will create the project using the specified name and settings.
38+
Once you've answered the prompts with the required configuration and selected a template, the CLI will create the
39+
project using the specified name and settings.
3840
See the following section to learn more about available CLI configurations.
3941

4042
## Options
@@ -46,14 +48,15 @@ The CLI provides the following options to display CLI details, and further custo
4648
| `-v` or `--version` | Check the current version of the `@metamask/create-gator-app` CLI. |
4749
| `-h` or `--help` | Display the available options. |
4850
| `--skip-install` | Skip the installation of dependencies. |
49-
| `--add-web3auth` | Add Web3Auth Embedded Wallet as a signer for the delegator account. <br/>Supported templates: <ul><li>Next.js starter</li><li> Vite React starter</li></ul> |
50-
| `--add-llm-rules` | Add LLM rules for your IDE. Supported templates: <ul><li>Next.js ERC-7715 starter</li></ul> |
51+
| `--add-web3auth` | Add [Web3Auth Embedded Wallet](https://web3auth.io/docs) as a signer for the delegator account.<br/>Supported templates:<br/>- MetaMask Smart Accounts Starter<br/>- MetaMask Smart Accounts & Delegation Starter |
52+
| `--add-llm-rules` | Add LLM rules for your IDE. Supported in the Experimental: ERC7715 Permissions Starter template. |
5153

5254
## Examples
5355

5456
### Web3Auth configuration
5557

56-
To create a project that uses [Web3Auth](https://web3auth.io/docs/) Embedded Wallet as the signer for your delegator account, use the `--add-web3auth` option with `@metamask/create-gator-app`:
58+
To create a project that uses [Web3Auth](https://web3auth.io/docs/) Embedded Wallet as the signer for your delegator
59+
account, use the `--add-web3auth` option with `@metamask/create-gator-app`:
5760

5861
```bash
5962
npx @metamask/create-gator-app --add-web3auth
@@ -89,5 +92,6 @@ Currently, only Cursor and Windsurf are supported.
8992
9093
| Template | Next.js | Vite React |
9194
|----------------------------------------------------|---------|------------|
92-
| Basic dapp with delegation and redeem flow | ✅ | ✅ |
93-
| Experimental: Basic dapp with ERC-7715 permissions | ✅ | |
95+
| MetaMask Smart Accounts Starter | ✅ | ✅ |
96+
| MetaMask Smart Accounts &amp; Delegation Starter | ✅ | ✅ |
97+
| Experimental: ERC7715 Permissions starter | ✅ | |

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

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ sidebar_position: 3
44
sidebar_label: Delegation quickstart
55
---
66

7-
# Delegation Toolkit quickstart
7+
# Delegation quickstart
88

9-
This page demonstrates how to get started quickly with the MetaMask Delegation Toolkit, by creating a delegator account and completing the delegation lifecycle (creating, signing, and redeeming a delegation).
9+
[Delegation](../concepts/delegation.md) is the ability for a [MetaMask smart account](../concepts/smart-accounts.md) to grant permission to another account to perform executions on its behalf.
10+
11+
In this quickstart, you will create a *delegator account* (the account that grants the permission) and *delegate account* (the account that receives the permission), and complete the delegation lifecycle (create, sign, and redeem a delegation).
12+
13+
This quickstart will refer to the delegator account as "Alice," who grants permission to "Bob," the delegate account, to perform executions on her behalf.
1014

1115
## Prerequisites
1216

@@ -43,9 +47,11 @@ const bundlerClient = createBundlerClient({
4347

4448
### 3. Create a delegator account
4549

46-
[Create a delegator smart account](../how-to/create-smart-account/index.md) to set up a delegation.
50+
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).
4752

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

5056
```typescript
5157
import { Implementation, toMetaMaskSmartAccount } from '@metamask/delegation-toolkit'
@@ -62,11 +68,15 @@ const delegatorSmartAccount = await toMetaMaskSmartAccount({
6268
})
6369
```
6470

71+
:::note
72+
See [how to configure other smart account types](../how-to/create-smart-account/configure-accounts-signers.md).
73+
:::
74+
6575
### 4. Create a delegate account
6676

67-
Create a delegate account to receive the delegation. The delegate can be either a smart account or an externally owned account (EOA).
77+
Create an account to represent Bob, the delegate who will receive the delegation. The delegate can be a smart account or an externally owned account (EOA).
6878

69-
This example uses a smart account:
79+
This example configures a Hybrid smart account:
7080

7181
```typescript
7282
import { Implementation, toMetaMaskSmartAccount } from '@metamask/delegation-toolkit'
@@ -85,13 +95,16 @@ const delegateSmartAccount = await toMetaMaskSmartAccount({
8595

8696
### 5. Create a delegation
8797

88-
[Create a root delegation](../how-to/create-delegation/index.md#create-a-root-delegation) from the delegator account to the delegate account.
98+
[Create a root delegation](../how-to/create-delegation/index.md#create-a-root-delegation) from Alice to Bob.
99+
A root delegation is a delegation that doesn't derive its authority from another delegation.
100+
Alice is delegating her own authority away, as opposed to *redelegating* permissions she received from a previous delegation.
89101

90-
This example passes an empty `caveats` array, which means the delegate can perform any action on the delegator's behalf. We recommend [restricting the delegation](../how-to/create-delegation/restrict-delegation.md) by adding caveat enforcers.
102+
This example passes an empty `caveats` array, which means Bob can perform any action on Alice's behalf. We recommend [restricting the delegation](../how-to/create-delegation/restrict-delegation.md) by adding caveat enforcers.
103+
For example, Alice can delegate the ability to sepnd her USDC to Bob, limiting the amount to 100 USDC.
91104

92105
:::warning Important
93106

94-
Before creating a delegation, ensure that the delegator account has been deployed. If the account is not deployed, redeeming the delegation will fail.
107+
Before creating a delegation, ensure that the delegator account (in this example, Alice's account) has been deployed. If the account is not deployed, redeeming the delegation will fail.
95108

96109
:::
97110

@@ -107,7 +120,7 @@ const delegation = createDelegation({
107120

108121
### 6. Sign the delegation
109122

110-
[Sign the delegation](../how-to/create-delegation/index.md#sign-a-delegation) using the [`signDelegation`](../reference/api/smart-account.md#signdelegation) method from `MetaMaskSmartAccount`. Alternatively, you can use the Delegation Toolkit's [`signDelegation`](../reference/api/delegation.md#signdelegation) utility. The signed delegation will be used later to perform actions on behalf of the delegator.
123+
[Sign the delegation](../how-to/create-delegation/index.md#sign-a-delegation) with Alice's account, using the [`signDelegation`](../reference/api/smart-account.md#signdelegation) method from `MetaMaskSmartAccount`. Alternatively, you can use the Delegation Toolkit's [`signDelegation`](../reference/api/delegation.md#signdelegation) utility. Bob will later use the signed delegation to perform actions on Alice's behalf.
111124

112125
```typescript
113126
const signature = await delegatorSmartAccount.signDelegation({
@@ -122,7 +135,7 @@ const signedDelegation = {
122135

123136
### 7. Redeem the delegation
124137

125-
The delegate account can now [redeem the delegation](../how-to/redeem-delegation.md). The redeem transaction is sent to the `DelegationManager` contract, which validates the delegation and executes actions on the delegator's behalf.
138+
Bob can now [redeem the delegation](../how-to/redeem-delegation.md). The redeem transaction is sent to the `DelegationManager` contract, which validates the delegation and executes actions on Alice's behalf.
126139

127140
To prepare the calldata for the redeem transaction, use the [`redeemDelegation`](../reference/api/delegation.md#redeemdelegation) utility function from the Delegation Toolkit.
128141

@@ -154,3 +167,8 @@ const userOperationHash = await bundlerClient.sendUserOperation({
154167
maxPriorityFeePerGas: 1n,
155168
})
156169
```
170+
171+
:::note
172+
If Bob's account (the delegate account) is an externally owned account (EOA) instead of a smart account,
173+
see [how to redeem the delegation with an EOA](../how-to/redeem-delegation.md#redeem-with-an-eoa).
174+
:::

delegation-toolkit/get-started/eip7715-quickstart.md renamed to delegation-toolkit/get-started/erc7715-quickstart.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
description: Learn how to use ERC-7715 to request permisisons.
2+
description: Learn how to use ERC-7715 to request permissions.
33
sidebar_position: 5
4-
sidebar_label: EIP-7715 quickstart
4+
sidebar_label: ERC-7715 quickstart
55
---
66

7-
# EIP-7715 quickstart
7+
# ERC-7715 quickstart
88

99
This page demonstrates how to use [ERC-7715](https://eips.ethereum.org/EIPS/eip-7715) to request permissions
1010
from a wallet, and execute transactions on a user's behalf.
1111

1212
## Prerequisites
1313

1414
- [Install and set up the Delegation Toolkit.](install.md)
15-
- [Install MetaMask Flask 12.14.2 or later](/snaps/get-started/install-flask.md).
15+
- [Install MetaMask Flask 12.14.2 or later](/snaps/get-started/install-flask).
1616

1717
## Steps
1818

@@ -159,4 +159,4 @@ const userOperationHash = await bundlerClient.sendUserOperationWithDelegation({
159159
maxPriorityFeePerGas: 1n
160160
accountMetadata,
161161
});
162-
```
162+
```

delegation-toolkit/get-started/quickstart.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
description: Get started quickly with the MetaMask Smart Accounts
33
sidebar_position: 2
4-
sidebar_label: Quickstart
4+
sidebar_label: Smart account quickstart
55
---
66

77
# MetaMask Smart Accounts quickstart
88

9-
This page demonstrates how to get started quickly with MetaMask Smart Accounts, and send the first user operation.
9+
This page demonstrates how to get started quickly with [MetaMask Smart Accounts](../concepts/smart-accounts.md), and send the first user operation.
1010

1111
## Prerequisites
1212

@@ -45,7 +45,8 @@ const bundlerClient = createBundlerClient({
4545

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

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

5051
```typescript
5152
import { Implementation, toMetaMaskSmartAccount } from "@metamask/delegation-toolkit";
@@ -62,6 +63,10 @@ const smartAccount = await toMetaMaskSmartAccount({
6263
});
6364
```
6465

66+
:::note
67+
See [how to configure other smart account types](../how-to/create-smart-account/configure-accounts-signers.md).
68+
:::
69+
6570
### 4. Send a user operation
6671

6772
Send a user operation using Viem's [`sendUserOperation`](https://viem.sh/account-abstraction/actions/bundler/sendUserOperation) method.

delegation-toolkit/how-to/configure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The MetaMask Delegation Toolkit provides custom middleware for [Pimlico's](https
1818
## Prerequisites
1919

2020
- [Install and set up the Delegation Toolkit](../get-started/install.md).
21-
- Optionally, complete the [Delegation Toolkit quickstart](../get-started/quickstart.md) to
21+
- Optionally, complete the [smart account quickstart](../get-started/quickstart.md) or [delegation quickstart](../get-started/delegation-quickstart.md) to
2222
familiarize yourself with the toolkit's capabilities.
2323

2424
## Viem's Account Abstraction API

delegation-toolkit/how-to/create-smart-account/configure-accounts-signers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To configure a Hybrid smart account, provide the following parameters:
3434

3535
:::note
3636
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 recoverability.
37+
However, we recommend configuring at least one signer for account recovery.
3838
:::
3939

4040
For a Hybrid smart account, you can configure the following types of signatories:
@@ -442,4 +442,4 @@ export const walletClient = createWalletClient({
442442
```
443443

444444
</TabItem>
445-
</Tabs>
445+
</Tabs>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TabItem from "@theme/TabItem";
99
# Generate a multisig signature
1010

1111
The MetaMask Delegation Toolkit supports [Multisig smart accounts](../concepts/smart-accounts.md#multisig-smart-account),
12-
allowing you to add multiple externally owned account (EOA)
12+
allowing you to add multiple externally owned accounts (EOA)
1313
signers with a configurable execution threshold. When the threshold
1414
is greater than 1, you can collect signatures from the required signers
1515
and use the [`aggregateSignature`](../reference/api/smart-account.md#aggregatesignature) function to combine them

delegation-toolkit/index.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,28 @@ Check out the following guides to get started with the MetaMask Delegation Toolk
4747
},
4848
{
4949
href: "get-started/quickstart",
50-
title: "Quickstart",
50+
title: "MetaMask Smart Accounts quickstart",
5151
description: "Create a MetaMask smart account and send a user operation.",
52+
},
53+
{
54+
href: "get-started/delegation-quickstart",
55+
title: "Delegation quickstart",
56+
description: "Create, sign, and redeem a delegation.",
57+
},
58+
{
59+
href: "get-started/eip7702-quickstart",
60+
title: "EIP-7702 quickstart",
61+
description: "Upgrade an externally owned account to a smart account.",
62+
},
63+
{
64+
href: "get-started/erc7715-quickstart",
65+
title: "ERC-7715 quickstart",
66+
description: "Request permissions from MetaMask and execute transactions on a user's behalf.",
67+
},
68+
{
69+
href: "get-started/cli-quickstart",
70+
title: "CLI quickstart",
71+
description: "Use the Delegation Toolkit CLI to bootstrap a project.",
5272
}
5373
]}
5474
/>

0 commit comments

Comments
 (0)