Skip to content

Commit 37056bc

Browse files
Improve delegation quickstarts (#2184)
* Improve delegation quickstarts * address some reviewer comments * updates * streamline delegation quickstart intro * minor fixes * their -> its
1 parent 81e1e38 commit 37056bc

File tree

7 files changed

+64
-21
lines changed

7 files changed

+64
-21
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Upon installation, you'll be asked the following prompts:
2727
vite-react
2828
? Pick a template: (Use arrow keys)
2929
❯ MetaMask Smart Accounts Starter
30-
MetaMask Smart Accounts & Delegation Starter
30+
MetaMask Smart Accounts & Delegation Starter
3131
Experimental: ERC7715 Permissions starter
3232
? Pick a package manager: (Use arrow keys)
3333
❯ npm

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
22
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

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/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)