You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Get started quickly with the MetaMask Delegation Toolkit.
3
+
sidebar_position: 3
4
+
sidebar_label: Delegation quickstart
5
+
---
6
+
7
+
# Delegation Toolkit quickstart
8
+
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).
10
+
11
+
## Prerequisites
12
+
13
+
[Install and set up the Delegation Toolkit.](install.md)
14
+
15
+
## Steps
16
+
17
+
### 1. Set up a Public Client
18
+
19
+
Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. This client will let the delegator account query the signer's account state and interact with smart contracts.
20
+
21
+
```typescript
22
+
import { createPublicClient, http } from'viem'
23
+
import { sepoliaaschain } from'viem/chains'
24
+
25
+
const publicClient =createPublicClient({
26
+
chain,
27
+
transport: http(),
28
+
})
29
+
```
30
+
31
+
### 2. Set up a Bundler Client
32
+
33
+
Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function. This lets you use the bundler service to estimate gas for user operations and submit transactions to the network.
[Create a root delegation](../how-to/create-delegation/index.md#create-a-root-delegation) from the delegator account to the delegate account.
89
+
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.
91
+
92
+
:::warning Important
93
+
94
+
Before creating a delegation, ensure that the delegator account has been deployed. If the account is not deployed, redeeming the delegation will fail.
[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.
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.
126
+
127
+
To prepare the calldata for the redeem transaction, use the [`redeemDelegation`](../reference/api/delegation.md#redeemdelegation) utility function from the Delegation Toolkit.
description: Get started quickly with the MetaMask Delegation Toolkit.
2
+
description: Get started quickly with the MetaMask Smart Accounts
3
3
sidebar_position: 2
4
4
sidebar_label: Quickstart
5
5
---
6
6
7
-
# Delegation Toolkit quickstart
7
+
# MetaMask Smart Accounts quickstart
8
8
9
-
This page demonstrates how to get started quickly with the MetaMask Delegation Toolkit,
10
-
by creating a delegator account and completing the delegation lifecycle (creating, signing, and redeeming a delegation).
9
+
This page demonstrates how to get started quickly with MetaMask Smart Accounts, and send the first user operation.
11
10
12
11
## Prerequisites
13
12
@@ -17,13 +16,12 @@ by creating a delegator account and completing the delegation lifecycle (creatin
17
16
18
17
### 1. Set up a Public Client
19
18
20
-
Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function.
21
-
This client will let the delegator account query the signer's account state and interact with smart contracts.
19
+
Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. This client will let the smart account query the signer's account state and interact with blockchain network.
Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function.
36
-
This lets you use the bundler service to estimate gas for user operations and submit transactions to the network.
33
+
Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function. This lets you use the bundler service to estimate gas for user operations and submit transactions to the network.
[Sign the delegation](../how-to/create-delegation/index.md#sign-a-delegation) using the [`signDelegation`](../reference/api/smart-account.md#signdelegation) method from `MetaMaskSmartAccount`.
124
-
Alternatively, you can use the Delegation Toolkit's [`signDelegation`](../reference/api/delegation.md#signdelegation) utility.
125
-
The signed delegation will be used later to perform actions on behalf of the delegator.
The delegate account can now [redeem the delegation](../how-to/redeem-delegation.md).
141
-
The redeem transaction is sent to the `DelegationManager` contract, which validates the delegation and
142
-
executes actions on the delegator's behalf.
67
+
Send a user operation using Viem's [`sendUserOperation`](https://viem.sh/account-abstraction/actions/bundler/sendUserOperation) method.
143
68
144
-
To prepare the calldata for the redeem transaction, use the [`redeemDelegation`](../reference/api/delegation.md#redeemdelegation) utility function from the Delegation Toolkit.
69
+
See [send user operation](./../how-to/send-user-operation.md) to learn how to estimate fee per gas, and wait for the transaction receipt.
0 commit comments