Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ You can use methods provided by the `DelegationStorageClient` of the MetaMask De
## Prerequisites

- [Install and set up the Delegation Toolkit.](../get-started/install.md)
- [Configure the Delegation Toolkit.](../guides/configure.md)
- Ensure you have an API key and API key ID to interact with the `DelegationStorageClient`.
If you need to gain access, email hellogators@consensys.net.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
---
description: Learn about the delegator environment object `DeleGatorEnvironment` and how to use it.
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
sidebar_label: Configure the toolkit
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# Delegator environment
# Configure the Delegation Toolkit

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.
The MetaMask Delegation toolkit is highly configurable, providing support for custom [bundlers and paymasters](#configure-the-bundler).
You can also configure the [toolkit environment](#configure-the-toolkit-environment) to interact with the [Delegation Framework](../concepts/delegation/index.md#delegation-framework).

The delegator environment serves several key purposes:
## Prerequisites

[Install and set up the Delegation Toolkit.](../get-started/install.md)

## Configure the bundler

The toolkit uses Viem's Account Abstraction API to configure custom bundlers and paymasters.
This provides a robust and flexible foundation for creating and managing [MetaMask Smart Accounts](../concepts/smart-accounts.md).
See Viem's [account abstraction documentation](https://viem.sh/account-abstraction) for more information on the API's features, methods, and best practices.

To use the bundler and paymaster clients with the toolkit, create instances of these clients and configure them as follows:

```typescript
import {
createPaymasterClient,
createBundlerClient,
} from "viem/account-abstraction";
import { http } from "viem";
import { sepolia as chain } from "viem/chains";

// Replace these URLs with your actual bundler and paymaster endpoints.
const bundlerUrl = "https://your-bundler-url.com";
const paymasterUrl = "https://your-paymaster-url.com";

// The paymaster is optional.
const paymasterClient = createPaymasterClient({
transport: http(paymasterUrl),
});

const bundlerClient = createBundlerClient({
transport: http(bundlerUrl),
paymaster: paymasterClient,
chain,
});
```

Replace the bundler and paymaster URLs with your bundler and paymaster endpoints.
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).

:::note
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.
:::

## (Optional) Configure the toolkit environment

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.
It serves several key purposes:

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

## Resolve the delegator environment
### Resolve the environment

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

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

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

```typescript
import {
Expand All @@ -82,7 +130,7 @@ import {
const environment: DeleGatorEnvironment = getDelegatorEnvironment(11155111);
```

## Deploy custom delegator environment
### Deploy a custom environment

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.

Expand Down Expand Up @@ -154,11 +202,11 @@ const environment = await deployDeleGatorEnvironment(
);
```

Once the contracts are deployed, you can use them to override the delegator environment.
Once the contracts are deployed, you can use them to override the environment.

## Override delegator environment
### Override the environment

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

```typescript
Expand Down
58 changes: 0 additions & 58 deletions delegation-toolkit/guides/configure.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ An account's supported *signatories* can sign data on behalf of the smart accoun

## Prerequisites

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

## Create a Hybrid smart account

Expand Down Expand Up @@ -413,7 +412,7 @@ export const walletClient = createWalletClient({

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

- In conjunction with [Viem Account Abstraction clients](../configure.md), [deploy the smart account](deploy-smart-account.md)
- In conjunction with [Viem Account Abstraction clients](../configure-toolkit.md), [deploy the smart account](deploy-smart-account.md)
and [send user operations](send-user-operation.md).
- [Create delegations](../delegation/execute-on-smart-accounts-behalf.md) that can be used to grant specific rights and permissions to other accounts.
Smart accounts that create delegations are called *delegator accounts*.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ the first user operation, or manually deploy the account.
## Prerequisites

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

## Deploy with the first user operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ into a single aggregated signature.
## Prerequisites

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

## Generate a multisig signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ You can use any paymaster service provider, such as [Pimlico](https://docs.pimli
## Prerequisites

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

## Send a gasless transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ If a user operation is sent from a MetaMask smart account that has not been depl
## Prerequisites

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

## Send a user operation
Expand Down
3 changes: 1 addition & 2 deletions gator-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ const sidebar = {
'concepts/delegation/caveat-enforcers',
],
},
'concepts/environment',
],
},
{
type: 'category',
label: 'Guides',
collapsed: false,
items: [
'guides/configure',
'guides/configure-toolkit',
{
type: 'category',
label: 'MetaMask Smart Accounts',
Expand Down
6 changes: 5 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
},
{
"source": "/delegation-toolkit/development/how-to/configure/",
"destination": "/delegation-toolkit/development/guides/configure/"
"destination": "/delegation-toolkit/development/guides/configure-toolkit/"
},
{
"source": "/delegation-toolkit/development/how-to/create-delegation/",
Expand Down Expand Up @@ -766,6 +766,10 @@
"source": "/delegation-toolkit/development/concepts/caveat-enforcers/",
"destination": "/delegation-toolkit/development/concepts/delegation/caveat-enforcers/"
},
{
"source": "/delegation-toolkit/development/concepts/environment/",
"destination": "/delegation-toolkit/development/guides/configure-toolkit/"
},
{
"source": "/developer-tools/faucet/sepolia/",
"destination": "/developer-tools/faucet/"
Expand Down
Loading