Skip to content

Commit e32658e

Browse files
alexandratranbgravenorstAyushBherwani1998
authored
Add DTK configure environment page (#2303)
* Add DTK configure environment page * remove old configure page * add bundler config and fix links * combine pages and edit * Update delegation-toolkit/guides/configure-toolkit.md Co-authored-by: Byron Gravenorst <[email protected]> * Update delegation-toolkit/guides/configure-toolkit.md Co-authored-by: Ayush Bherwani <[email protected]> --------- Co-authored-by: Byron Gravenorst <[email protected]> Co-authored-by: Ayush Bherwani <[email protected]>
1 parent 735cb0a commit e32658e

File tree

10 files changed

+67
-80
lines changed

10 files changed

+67
-80
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ You can use methods provided by the `DelegationStorageClient` of the MetaMask De
1818
## Prerequisites
1919

2020
- [Install and set up the Delegation Toolkit.](../get-started/install.md)
21-
- [Configure the Delegation Toolkit.](../guides/configure.md)
2221
- Ensure you have an API key and API key ID to interact with the `DelegationStorageClient`.
2322
If you need to gain access, email [email protected].
2423

delegation-toolkit/concepts/environment.md renamed to delegation-toolkit/guides/configure-toolkit.md

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,71 @@
11
---
2-
description: Learn about the delegator environment object `DeleGatorEnvironment` and how to use it.
2+
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
3+
sidebar_label: Configure the toolkit
34
---
45

56
import Tabs from "@theme/Tabs";
67
import TabItem from "@theme/TabItem";
78

8-
# Delegator environment
9+
# Configure the Delegation Toolkit
910

10-
The `DeleGatorEnvironment` object is a component of the MetaMask Delegation Toolkit that defines the contract addresses necessary for interacting with the [Delegation Framework](delegation/index.md#delegation-framework) on a specific network.
11+
The MetaMask Delegation toolkit is highly configurable, providing support for custom [bundlers and paymasters](#configure-the-bundler).
12+
You can also configure the [toolkit environment](#configure-the-toolkit-environment) to interact with the [Delegation Framework](../concepts/delegation/index.md#delegation-framework).
1113

12-
The delegator environment serves several key purposes:
14+
## Prerequisites
15+
16+
[Install and set up the Delegation Toolkit.](../get-started/install.md)
17+
18+
## Configure the bundler
19+
20+
The toolkit uses Viem's Account Abstraction API to configure custom bundlers and paymasters.
21+
This provides a robust and flexible foundation for creating and managing [MetaMask Smart Accounts](../concepts/smart-accounts.md).
22+
See Viem's [account abstraction documentation](https://viem.sh/account-abstraction) for more information on the API's features, methods, and best practices.
23+
24+
To use the bundler and paymaster clients with the toolkit, create instances of these clients and configure them as follows:
25+
26+
```typescript
27+
import {
28+
createPaymasterClient,
29+
createBundlerClient,
30+
} from "viem/account-abstraction";
31+
import { http } from "viem";
32+
import { sepolia as chain } from "viem/chains";
33+
34+
// Replace these URLs with your actual bundler and paymaster endpoints.
35+
const bundlerUrl = "https://your-bundler-url.com";
36+
const paymasterUrl = "https://your-paymaster-url.com";
37+
38+
// The paymaster is optional.
39+
const paymasterClient = createPaymasterClient({
40+
transport: http(paymasterUrl),
41+
});
42+
43+
const bundlerClient = createBundlerClient({
44+
transport: http(bundlerUrl),
45+
paymaster: paymasterClient,
46+
chain,
47+
});
48+
```
49+
50+
Replace the bundler and paymaster URLs with your bundler and paymaster endpoints.
51+
For example, you can use endpoints from [Pimlico](https://docs.pimlico.io/references/bundler), [Infura](/services), or [ZeroDev](https://docs.zerodev.app/meta-infra/intro).
52+
53+
:::note
54+
Providing a paymaster is optional when configuring your bundler client. However, if you choose not to use a paymaster, the smart contract account must have enough funds to pay gas fees.
55+
:::
56+
57+
## (Optional) Configure the toolkit environment
58+
59+
The toolkit environment (`DeleGatorEnvironment`) defines the contract addresses necessary for interacting with the [Delegation Framework](../concepts/delegation/index.md#delegation-framework) on a specific network.
60+
It serves several key purposes:
1361

1462
- It provides a centralized configuration for all the contract addresses required by the Delegation Framework.
1563
- It enables easy switching between different networks (for example, Mainnet and testnet) or custom deployments.
1664
- It ensures consistency across different parts of the application that interact with the Delegation Framework.
1765

18-
## Resolve the delegator environment
66+
### Resolve the environment
1967

20-
When you create a [MetaMask smart account](smart-accounts.md), the Delegation Toolkit automatically
68+
When you create a [MetaMask smart account](../concepts/smart-accounts.md), the toolkit automatically
2169
resolves the environment based on the version it requires and the chain configured.
2270
If no environment is found for the specified chain, it throws an error.
2371

@@ -70,7 +118,7 @@ See the changelog of the toolkit version you are using (in the left sidebar) for
70118

71119
Alternatively, you can use the [`getDelegatorEnvironment`](../reference/api/delegation.md#getdelegatorenvironment) function to resolve the environment.
72120
This function is especially useful if your delegator is not a smart account when
73-
creating a [redelegation](delegation/index.md#delegation-types).
121+
creating a [redelegation](../concepts/delegation/index.md#delegation-types).
74122

75123
```typescript
76124
import {
@@ -82,7 +130,7 @@ import {
82130
const environment: DeleGatorEnvironment = getDelegatorEnvironment(11155111);
83131
```
84132

85-
## Deploy custom delegator environment
133+
### Deploy a custom environment
86134

87135
You can deploy the contracts using any method, but the toolkit provides a convenient [`deployDelegatorEnvironment`](../reference/api/delegation.md#deploydelegatorenvironment) function. This function simplifies deploying the Delegation Framework contracts to your desired EVM chain.
88136

@@ -154,11 +202,11 @@ const environment = await deployDeleGatorEnvironment(
154202
);
155203
```
156204

157-
Once the contracts are deployed, you can use them to override the delegator environment.
205+
Once the contracts are deployed, you can use them to override the environment.
158206

159-
## Override delegator environment
207+
### Override the environment
160208

161-
To override the delegator environment, the toolkit provides an [`overrideDeployedEnvironment`](../reference/api/delegation.md#overridedeployedenvironment) function to resolve
209+
To override the environment, the toolkit provides an [`overrideDeployedEnvironment`](../reference/api/delegation.md#overridedeployedenvironment) function to resolve
162210
`DeleGatorEnvironment` with specified contracts for the given chain and contract version.
163211

164212
```typescript

delegation-toolkit/guides/configure.md

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

delegation-toolkit/guides/smart-accounts/create-smart-account.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ An account's supported *signatories* can sign data on behalf of the smart accoun
1313

1414
## Prerequisites
1515

16-
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
17-
- [Configure the Delegation Toolkit.](../configure.md)
16+
[Install and set up the Delegation Toolkit.](../../get-started/install.md)
1817

1918
## Create a Hybrid smart account
2019

@@ -413,7 +412,7 @@ export const walletClient = createWalletClient({
413412

414413
With a MetaMask smart account, you can perform the following functions:
415414

416-
- In conjunction with [Viem Account Abstraction clients](../configure.md), [deploy the smart account](deploy-smart-account.md)
415+
- In conjunction with [Viem Account Abstraction clients](../configure-toolkit.md), [deploy the smart account](deploy-smart-account.md)
417416
and [send user operations](send-user-operation.md).
418417
- [Create delegations](../delegation/execute-on-smart-accounts-behalf.md) that can be used to grant specific rights and permissions to other accounts.
419418
Smart accounts that create delegations are called *delegator accounts*.

delegation-toolkit/guides/smart-accounts/deploy-smart-account.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ the first user operation, or manually deploy the account.
1313
## Prerequisites
1414

1515
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
16-
- [Configure the Delegation Toolkit.](../configure.md)
1716
- [Create a MetaMask smart account.](create-smart-account.md)
1817

1918
## Deploy with the first user operation

delegation-toolkit/guides/smart-accounts/generate-multisig-signature.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ into a single aggregated signature.
1717
## Prerequisites
1818

1919
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
20-
- [Configure the Delegation Toolkit.](../configure.md)
2120
- [Create a Multisig smart account.](create-smart-account.md#create-a-multisig-smart-account)
2221

2322
## Generate a multisig signature

delegation-toolkit/guides/smart-accounts/send-gasless-transaction.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ You can use any paymaster service provider, such as [Pimlico](https://docs.pimli
1313
## Prerequisites
1414

1515
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
16-
- [Configure the Delegation Toolkit.](../configure.md)
1716
- [Create a MetaMask smart account.](create-smart-account.md)
1817

1918
## Send a gasless transaction

delegation-toolkit/guides/smart-accounts/send-user-operation.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ If a user operation is sent from a MetaMask smart account that has not been depl
2525
## Prerequisites
2626

2727
- [Install and set up the Delegation Toolkit.](../../get-started/install.md)
28-
- [Configure the Delegation Toolkit.](../configure.md)
2928
- [Create a MetaMask smart account.](create-smart-account.md)
3029

3130
## Send a user operation

gator-sidebar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ const sidebar = {
4343
'concepts/delegation/caveat-enforcers',
4444
],
4545
},
46-
'concepts/environment',
4746
],
4847
},
4948
{
5049
type: 'category',
5150
label: 'Guides',
5251
collapsed: false,
5352
items: [
54-
'guides/configure',
53+
'guides/configure-toolkit',
5554
{
5655
type: 'category',
5756
label: 'MetaMask Smart Accounts',

vercel.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@
732732
},
733733
{
734734
"source": "/delegation-toolkit/development/how-to/configure/",
735-
"destination": "/delegation-toolkit/development/guides/configure/"
735+
"destination": "/delegation-toolkit/development/guides/configure-toolkit/"
736736
},
737737
{
738738
"source": "/delegation-toolkit/development/how-to/create-delegation/",
@@ -766,6 +766,10 @@
766766
"source": "/delegation-toolkit/development/concepts/caveat-enforcers/",
767767
"destination": "/delegation-toolkit/development/concepts/delegation/caveat-enforcers/"
768768
},
769+
{
770+
"source": "/delegation-toolkit/development/concepts/environment/",
771+
"destination": "/delegation-toolkit/development/guides/configure-toolkit/"
772+
},
769773
{
770774
"source": "/developer-tools/faucet/sepolia/",
771775
"destination": "/developer-tools/faucet/"

0 commit comments

Comments
 (0)