Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion delegation-toolkit/concepts/delegation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_position: 2

# Delegation

*Delegation* is the ability for a [smart account](smart-accounts.md) to grant permission to another smart account
*Delegation* is the ability for a [Smart Account](smart-accounts.md) to grant permission to another Smart Account
or externally owned account (EOA) to perform specific executions on their behalf, under defined rules and restrictions.
The account that grants the permission is called the *delegator account*, while the account that receives the permission
is called the *delegate account*.
Expand Down
4 changes: 2 additions & 2 deletions delegation-toolkit/concepts/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The delegator environment serves several key purposes:

## Resolve the delegator environment

When you create a [MetaMask smart account](smart-accounts.md), the Delegation Toolkit automatically
When you create a [MetaMask Smart Account](smart-accounts.md), the Delegation 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 +70,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
This function is especially useful if your delegator is not a Smart Account when
[creating a redelegation](../how-to/create-delegation/index.md#create-a-redelegation).

```typescript
Expand Down
49 changes: 24 additions & 25 deletions delegation-toolkit/concepts/smart-accounts.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
---
description: Learn about MetaMask smart accounts.
description: Learn about MetaMask Smart Accounts.
sidebar_position: 1
---

# Smart accounts
# MetaMask Smart Accounts

The MetaMask Delegation Toolkit enables you to create and manage MetaMask *smart accounts*.
Smart accounts are [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart contract accounts
The MetaMask Delegation Toolkit enables you to create and manage MetaMask Smart Accounts.
Smart Accounts are [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart contract accounts
that support programmable account behavior and advanced features such as multi-signature approvals,
automated transaction batching, and custom security policies.
Unlike traditional wallets, which rely on private keys for every transaction, MetaMask smart
accounts use smart contracts to govern account logic.
Unlike traditional wallets, which rely on private keys for every transaction, MetaMask Smart Accounts use smart contracts to govern account logic.

Smart accounts are referenced in the toolkit as `MetaMaskSmartAccount`.
Smart Accounts are referenced in the toolkit as `MetaMaskSmartAccount`.

## Account abstraction (ERC-4337)

Account abstraction, specified by [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337), is a
mechanism that enables users to manage smart accounts containing arbitrary verification logic.
mechanism that enables users to manage smart contract accounts containing arbitrary verification logic.
ERC-4337 enables smart contracts to be used as primary accounts in place of traditional private key-based
accounts, or externally owned accounts (EOAs).

ERC-4337 introduces the following concepts:

- **User operation** - A package of instructions signed by a user, specifying executions for
the smart account to perform.
the Smart Account to perform.
User operations are collected and submitted to the network by bundlers.

- **Bundler** - A service that collects multiple user operations, packages them into a single transaction,
Expand All @@ -34,42 +33,42 @@ ERC-4337 introduces the following concepts:
adhere to the required rules and security checks.

- **Paymasters** - Entities that handle the payment of gas fees on behalf of users, often integrated
into smart accounts to facilitate gas abstraction.
into Smart Accounts to facilitate gas abstraction.

## Smart account implementation types
## Smart Account implementation types

The MetaMask Delegation Toolkit supports three types of smart accounts, each offering unique features and use cases.
The MetaMask Delegation Toolkit supports three types of Smart Accounts, each offering unique features and use cases.

See [Configure accounts and signers](../how-to/create-smart-account/configure-accounts-signers.md) to learn how to use these different account types.

### Hybrid smart account
### Hybrid Smart Account

The Hybrid smart account is a flexible implementation that supports both an externally owned account (EOA) "owner" and any number of P256 (passkey) signers.
You can configure any of these signers as the signatory, and use them to sign any data, including user operations, on behalf of the smart account.
The Hybrid Smart Account is a flexible implementation that supports both an externally owned account (EOA) "owner" and any number of P256 (passkey) signers.
You can configure any of these signers as the signatory, and use them to sign any data, including user operations, on behalf of the Smart Account.

This type is referenced in the toolkit as `Implementation.Hybrid`.

### Multisig smart account
### Multisig Smart Account

The Multisig smart account is an implementation that supports multiple signers with a configurable threshold for valid signatures, allowing for enhanced security and flexibility in account management.
The Multisig Smart Account is an implementation that supports multiple signers with a configurable threshold for valid signatures, allowing for enhanced security and flexibility in account management.
The signatory must have at least as many signers include as the threshold is configured for the account.

This type is referenced in the toolkit as `Implementation.Multisig`.

### Stateless 7702 smart account
### Stateless 7702 Smart Account

The Stateless 7702 smart account implementation represents an externally owned account (EOA) upgraded to
support smart account functionality as defined by [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702). This implementation enables EOAs to perform smart account operations, including the creation and management of delegations.
The Stateless 7702 Smart Account implementation represents an externally owned account (EOA) upgraded to
support Smart Account functionality as defined by [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702). This implementation enables EOAs to perform Smart Account operations, including the creation and management of delegations.

This type is referenced in the toolkit as `Implementation.Stateless7702`.

## Smart account flow
## Smart Account flow

The MetaMask smart account flow is as follows:
The MetaMask Smart Account flow is as follows:

1. **Account setup** - A user creates a smart account by deploying a smart contract, and initializing it with
1. **Account setup** - A user creates a Smart Account by deploying a smart contract, and initializing it with
ownership and security settings.
The user can customize the smart account in the following ways:
The user can customize the Smart Account in the following ways:

- **Account logic** - They can configure custom logic for actions such as multi-signature
approvals, spending limits, and automated transaction batching.
Expand All @@ -91,6 +90,6 @@ The MetaMask smart account flow is as follows:

## Delegator accounts

Delegator accounts are a type of smart account that allows users to grant permission to other smart accounts or EOAs
Delegator accounts are a type of Smart Account that allows users to grant permission to other Smart Accounts or EOAs
to perform specific executions on their behalf, under defined rules and restrictions.
Learn more about [delegation](delegation.md).
12 changes: 6 additions & 6 deletions delegation-toolkit/experimental/erc-7710-redeem-delegations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import TabItem from "@theme/TabItem";
This is an experimental feature and may change in future releases.
:::

[ERC-7710](https://eip.tools/eip/7710) introduces a standard way for smart accounts to delegate capabilities to other
smart accounts or externally owned accounts (EOAs).
[ERC-7710](https://eip.tools/eip/7710) introduces a standard way for Smart Accounts to delegate capabilities to other
Smart Accounts or externally owned accounts (EOAs).

The MetaMask Delegation Toolkit provides two experimental functions, `erc7710BundlerActions()` and `erc7710WalletActions()`, that let
a caller redeem delegations granted by MetaMask's permissions system.
Expand Down Expand Up @@ -57,7 +57,7 @@ const permissionsResponse = [{

const permissionsContext = permissionsResponse[0].context;
const delegationManager = permissionsResponse[0].signerMeta.delegationManager;
// accountMeta is only present when the smart account is not deployed.
// accountMeta is only present when the Smart Account is not deployed.
const accountMetadata = permissionsResponse[0].accountMeta;
```

Expand All @@ -80,11 +80,11 @@ If you redeem delegations in any other way, it is your responsibility to validat

## Redeem the permission

Redeem a delegation with a [smart account](#redeem-with-a-smart-account) or an [externally owned account (EOA)](#redeem-with-an-eoa).
Redeem a delegation with a [Smart Account](#redeem-with-a-smart-account) or an [externally owned account (EOA)](#redeem-with-an-eoa).

### Redeem with a smart account
### Redeem with a Smart Account

To redeem a delegation with a smart account, create a [`MetaMaskSmartAccount`](../how-to/create-smart-account/index.md#create-a-metamasksmartaccount)
To redeem a delegation with a Smart Account, create a [`MetaMaskSmartAccount`](../how-to/create-smart-account/index.md#create-a-metamasksmartaccount)
and a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler).

After setting up your Bundler Client, you can extend its functionality with `erc7710BundlerActions` actions to support ERC-7710. Once extended, use [`sendUserOperationWithDelegation`](../reference/api/experimental-actions/bundler-client.md#senduseroperationwithdelegation) to redeem the permission.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The MetaMask Delegation Toolkit provides the experimental actions for ERC-7715 t
## Request permissions

To request permissions, extend your [Viem Wallet Client](https://viem.sh/docs/clients/wallet) with `erc7715ProviderActions` actions.
You'll need a session account to request the permission, which can be either a smart account or an externally owned account (EOA).
This example uses a smart account:
You'll need a session account to request the permission, which can be either a Smart Account or an externally owned account (EOA).
This example uses a Smart Account:

<Tabs>
<TabItem value="example.ts">
Expand Down
10 changes: 5 additions & 5 deletions delegation-toolkit/get-started/eip7702-quickstart.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
description: Upgrade an externally owned account (EOA) to a smart account
description: Upgrade an externally owned account (EOA) to a Smart Account
sidebar_position: 3
sidebar_label: EIP-7702 quickstart
---

# EIP-7702 quickstart

This page demonstrates how to upgrade your externally owned account (EOA) to support MetaMask smart account
This page demonstrates how to upgrade your externally owned account (EOA) to support MetaMask Smart Account
functionality using an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) transaction. This enables your EOA to leverage the benefits of account
abstraction, such as batch transactions, gas sponsorship, and [ERC-7710 delegation capabilities](./../concepts/delegation.md).

Expand Down Expand Up @@ -73,7 +73,7 @@ does not support JSON-RPC accounts.

This example uses [`EIP7702StatelessDeleGator`](https://github.com/MetaMask/delegation-framework/blob/main/src/EIP7702/EIP7702StatelessDeleGator.sol) as the EIP-7702 delegator contract.
It follows a stateless design, as it does not store signer data in the contract's state. This approach
provides a lightweight and secure way to upgrade an EOA to a smart account.
provides a lightweight and secure way to upgrade an EOA to a Smart Account.

```typescript
import {
Expand Down Expand Up @@ -108,9 +108,9 @@ const hash = await walletClient.sendTransaction({
});
```

### 6. Create a MetaMask smart account
### 6. Create a MetaMask Smart Account

Create a smart account instance for the EOA and start
Create a Smart Account instance for the EOA and start
leveraging the benefits of account abstraction.

```ts
Expand Down
6 changes: 3 additions & 3 deletions delegation-toolkit/get-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TabItem from "@theme/TabItem";

# Install and set up the Delegation Toolkit

This page provides instructions to install and set up the MetaMask Delegation Toolkit.
This page provides instructions to install and set up the MetaMask Delegation Toolkit, enabling you to integrate [Smart Accounts](../concepts/smart-accounts.md) into your dapp.

## Prerequisites

Expand Down Expand Up @@ -44,5 +44,5 @@ Add `@metamask/delegation-framework/=lib/metamask/delegation-framework/` in your

### 3. Get started

You're now ready to start using the MetaMask Delegation Toolkit.
Check out the [Delegation Toolkit quickstart](quickstart.md) to walk through a simple example.
You're now ready to start using the Delegation Toolkit and MetaMask Smart Accounts.
Comment thread
alexandratran marked this conversation as resolved.
Outdated
Check out the [quickstart](quickstart.md) to walk through a simple example.
2 changes: 1 addition & 1 deletion delegation-toolkit/how-to/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Configure the toolkit

# Configure the Delegation Toolkit

The MetaMask Delegation Toolkit enables you to easily integrate [smart accounts](../concepts/smart-accounts.md) into your dapp,
The MetaMask Delegation Toolkit enables you to easily integrate [Smart Accounts](../concepts/smart-accounts.md) into your dapp,
enabling a more flexible, secure, and frictionless experience for your users.

The toolkit is highly configurable, allowing you to tailor it to your project's specific needs. It includes support for custom signers, multiple signatory schemes, custom paymasters and bundlers, and more.
Expand Down
6 changes: 3 additions & 3 deletions delegation-toolkit/how-to/create-delegation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Learn how to [restrict a delegation](./restrict-delegation.md) using caveat enfo

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

## Create a root delegation

Expand All @@ -44,7 +44,7 @@ import { createDelegation } from "@metamask/delegation-toolkit";
import { delegatorSmartAccount } from "./config.ts";

// The address to which the delegation is granted. It can be an EOA address, or
// smart account address.
// Smart Account address.
const delegate = "0x2FcB88EC2359fA635566E66415D31dD381CF5585";

const delegation = createDelegation({
Expand Down Expand Up @@ -298,7 +298,7 @@ import { createDelegation } from "@metamask/delegation-toolkit";
import { delegatorSmartAccount } from "./config.ts";

// The address to which the delegation is granted. It can be an EOA address, or
// smart account address.
// Smart Account address.
const delegate = "0x2FcB88EC2359fA635566E66415D31dD381CF5585";

const delegation = createDelegation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ sidebar_position: 1
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# Configure smart accounts and signers
# Configure Smart Accounts and signers

The MetaMask Delegation Toolkit supports different [smart account types](../../concepts/smart-accounts.md#smart-account-implementation-types),
The MetaMask Delegation Toolkit supports different [Smart Account types](../../concepts/smart-accounts.md#smart-account-implementation-types),
each with its own configuration and support for different signing mechanisms.
You can create flexible and secure delegator accounts tailored to your specific needs.

## Prerequisites

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

## Configure a Hybrid smart account
## Configure a Hybrid Smart Account

The [Hybrid smart account](../../concepts/smart-accounts.md#hybrid-smart-account) supports both an EOA "owner" and any number of P256 (passkey) signers.
The [Hybrid Smart Account](../../concepts/smart-accounts.md#hybrid-smart-account) supports both an EOA "owner" and any number of P256 (passkey) signers.

To configure a Hybrid smart account, provide the following parameters:
To configure a Hybrid Smart Account, provide the following parameters:

- `owner`: The owner's account address as a hex string.
The owner can be the zero address, indicating that there is no owner configured.
- `p256KeyIds`: An array of key identifiers for P256 signers as hex strings.
- `p256XValues`: An array of public key x-values for P256 signers as `bigint`s.
- `p256YValues`: An array of public key y-values for P256 signers as `bigint`s.
- `signatory`: A signer that will sign on behalf of the smart account.
- `signatory`: A signer that will sign on behalf of the Smart Account.

:::note
You can set all `p256` parameters to empty arrays to configure no WebAuthn signer.
However, we recommend configuring at least one signer for account recoverability.
:::

For a Hybrid smart account, you can configure the following types of signatories:
For a Hybrid Smart Account, you can configure the following types of signatories:

### Configure an account signatory

Expand Down Expand Up @@ -232,19 +232,19 @@ export const webAuthnAccount = toWebAuthnAccount({ credential });
</Tabs>


## Configure a Multisig smart account
## Configure a Multisig Smart Account

The [Multisig smart account](../../concepts/smart-accounts.md#multisig-smart-account) supports multiple EOA signers with a configurable threshold for execution.
The [Multisig Smart Account](../../concepts/smart-accounts.md#multisig-smart-account) supports multiple EOA signers with a configurable threshold for execution.

To configure a Multisig smart account, provide the following parameters:
To configure a Multisig Smart Account, provide the following parameters:

- `signers`: An array of EOA signer addresses as hex strings.
- `threshold`: The number of signers required to execute a transaction, as a `bigint`.
- `signatory`: A signer that will sign on behalf of the smart account.
- `signatory`: A signer that will sign on behalf of the Smart Account.

### Configure signatories

For a Multisig smart account, you can use a combination of account signatories and Wallet Client signatories.
For a Multisig Smart Account, you can use a combination of account signatories and Wallet Client signatories.
For example:

<Tabs>
Expand Down Expand Up @@ -316,17 +316,17 @@ export const walletClient = createWalletClient({
The number of signers in the signatories must be at least equal to the threshold for valid signature generation.
:::

## Configure a Stateless 7702 smart account
## Configure a Stateless 7702 Smart Account

The [Stateless 7702 smart account](../../concepts/smart-accounts.md#stateless-7702-smart-account) represents an EOA that has been upgraded to support smart account
The [Stateless 7702 Smart Account](../../concepts/smart-accounts.md#stateless-7702-smart-account) represents an EOA that has been upgraded to support Smart Account
functionality as defined by [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702). This implementation does not handle the upgrade process; see the [EIP-7702 quickstart](./../../get-started/eip7702-quickstart.md) to learn how to upgrade.

To configure a Stateless 7702 smart account, provide the following parameters:
To configure a Stateless 7702 Smart Account, provide the following parameters:

- `address`: The address of the EOA that has been upgraded to a smart account.
- `signatory`: A signer that will sign on behalf of the smart account.
- `address`: The address of the EOA that has been upgraded to a Smart Account.
- `signatory`: A signer that will sign on behalf of the Smart Account.

For a Stateless 7702 smart account, you can configure the following types of signatories:
For a Stateless 7702 Smart Account, you can configure the following types of signatories:

### Configure an account signatory

Expand Down
Loading
Loading