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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ Build the documentation site locally using the following steps.
npm start
```

Once the server starts, you can view the documentation at `http://localhost:3000`.
Once the server starts, you can view the documentation at `http://localhost:3003`.

For more information on contributing to the documentation, see the [full contribution guidelines](CONTRIBUTING.md).
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ const sessionAccount = privateKeyToAccount("0x...");

### 4. Check the EOA account code

Advanced Permissions support the automatic upgrading of a MetaMask user's account to a [MetaMask smart account](../../concepts/smart-accounts.md),
when using MetaMask Flask version 13.9.0 or later. For earlier versions, you must ensure that the
user is upgraded to a smart account before requesting Advanced Permissions.
With MetaMask Flask 13.9.0 or later, Advanced Permissions support automatically upgrading a user’s
account to a [MetaMask smart account](../../concepts/smart-accounts.md). On earlier versions, upgrade
the user to a smart account before requesting Advanced Permissions.

If the user has not yet been upgraded, you can handle the upgrade [programmatically](/wallet/how-to/send-transactions/send-batch-transactions/#about-atomic-batch-transactions) or ask the
user to [switch to a smart account manually](https://support.metamask.io/configure/accounts/switch-to-or-revert-from-a-smart-account/#how-to-switch-to-a-metamask-smart-account).
Expand Down Expand Up @@ -140,7 +140,7 @@ if (code) {

### 5. Request Advanced Permissions

Request Advanced Permissions from the user using the Wallet Client's `requestExecutionPermissions` action.
Request Advanced Permissions from the user with the Wallet Client's `requestExecutionPermissions` action.
In this example, you'll request an
[ERC-20 periodic permission](use-permissions/erc20-token.md#erc-20-periodic-permission).

Expand Down
24 changes: 12 additions & 12 deletions gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
sidebar_label: Configure the toolkit
keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment]
keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment]
---

import Tabs from "@theme/Tabs";
Expand Down Expand Up @@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551

### Deploy a custom environment

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

This function requires a Viem [Public Client](https://viem.sh/docs/clients/public), [Wallet Client](https://viem.sh/docs/clients/wallet), and [Chain](https://viem.sh/docs/glossary/types#chain)
to deploy the contracts and resolve the `SmartAccountsEnvironment`.
Expand All @@ -146,9 +146,9 @@ Your wallet must have a sufficient native token balance to deploy the contracts.
```typescript
import { walletClient, publicClient } from "./config.ts";
import { sepolia as chain } from "viem/chains";
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";

const environment = await deployDeleGatorEnvironment(
const environment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand Down Expand Up @@ -182,16 +182,16 @@ export const publicClient = createPublicClient({
</TabItem>
</Tabs>

You can also override specific contracts when calling `deployDelegatorEnvironment`.
You can also override specific contracts when calling `deploySmartAccountsEnvironment`.
For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function.

```typescript
// The config.ts is the same as in the previous example.
import { walletClient, publicClient } from "./config.ts";
import { sepolia as chain } from "viem/chains";
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";

const environment = await deployDeleGatorEnvironment(
const environment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain,
Expand All @@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains";
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
import {
overrideDeployedEnvironment,
deployDeleGatorEnvironment
deploySmartAccountsEnvironment
} from "@metamask/smart-accounts-kit";

const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand All @@ -233,7 +233,7 @@ overrideDeployedEnvironment(
);
```

If you've already deployed the contracts using a different method, you can create a `DelegatorEnvironment` instance with the required contract addresses, and pass it to the function.
If you've already deployed the contracts using a different method, you can create a `SmartAccountsEnvironment` instance with the required contract addresses, and pass it to the function.

```typescript
// remove-start
Expand All @@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
import {
overrideDeployedEnvironment,
// remove-next-line
- deployDeleGatorEnvironment
- deploySmartAccountsEnvironment
} from "@metamask/smart-accounts-kit";

// remove-start
- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
- walletClient,
- publicClient,
- chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const delegation = createDelegation({
// Address to which the delegation is being granted
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
// Alternatively you can use environment property of MetaMask smart account.
environment: getSmartAccountsEnvironment(sepolia.id);
environment: getSmartAccountsEnvironment(sepolia.id),
scope: {
type: "nativeTokenTransferAmount",
// 0.001 ETH in wei format.
Expand Down Expand Up @@ -145,7 +145,7 @@ const delegation = createOpenDelegation({
// Address that is granting the delegation
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
// Alternatively you can use environment property of MetaMask smart account.
environment: getSmartAccountsEnvironment(sepolia.id);
environment: getSmartAccountsEnvironment(sepolia.id),
scope: {
type: "nativeTokenTransferAmount",
// 0.001 ETH in wei format.
Expand Down Expand Up @@ -182,7 +182,25 @@ const execution = createExecution({
});
```

## `deployDeleGatorEnvironment`
## `decodeDelegations`

Decodes an ABI-encoded hex string to an array of delegations.

### Parameters

| Name | Type | Required | Description |
| ---- | ---- | -------- | ----------- |
| `encoded` | `Hex` | Yes | The ABI encoded hex string to decode. |

### Example

```ts
import { decodeDelegations } from "@metamask/smart-accounts-kit/utils";

const delegations = decodeDelegations("0x7f0db33d..c06aeeac");
```

## `deploySmartAccountsEnvironment`

Deploys the Delegation Framework contracts to an EVM chain.

Expand All @@ -201,11 +219,11 @@ Deploys the Delegation Framework contracts to an EVM chain.
<TabItem value="example.ts">

```ts
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
import { walletClient, publicClient } from "./config.ts";
import { sepolia as chain } from "viem/chains";

const environment = await deployDeleGatorEnvironment(
const environment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand Down Expand Up @@ -250,10 +268,10 @@ import { sepolia as chain } from "viem/chains";
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
import {
overrideDeployedEnvironment,
deployDeleGatorEnvironment,
deploySmartAccountsEnvironment,
} from "@metamask/smart-accounts-kit/utils";

const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand Down Expand Up @@ -303,7 +321,7 @@ import { parseEther } from "viem";
export const delegation = createDelegation({
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
environment: getSmartAccountsEnvironment(sepolia.id);
environment: getSmartAccountsEnvironment(sepolia.id),
scope: {
type: "nativeTokenTransferAmount",
// 0.001 ETH in wei format.
Expand All @@ -315,6 +333,50 @@ export const delegation = createDelegation({
</TabItem>
</Tabs>

## `encodeDelegations`

Encodes an array of delegations to an ABI-encoded hex string.

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `delegations` | `Delegation[]` | Yes | The delegation array to be encoded. |

### Example

<Tabs>
<TabItem value="example.ts">

```ts
import { encodeDelegations } from "@metamask/smart-accounts-kit/utils";
import { delegation } from "./delegation.ts";

const encodedDelegations = encodeDelegations([delegation]);
```

</TabItem>
<TabItem value="delegation.ts">

```ts
import { createDelegation } from "@metamask/smart-accounts-kit";
import { sepolia } from "viem/chains";
import { parseEther } from "viem";

export const delegation = createDelegation({
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
environment: getSmartAccountsEnvironment(sepolia.id),
scope: {
type: "nativeTokenTransferAmount",
// 0.001 ETH in wei format.
maxAmount: parseEther("0.001"),
},
});
```

</TabItem>
</Tabs>

## `getDelegationHashOffchain`

Expand Down
5 changes: 5 additions & 0 deletions gator_versioned_sidebars/version-0.1.0-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"get-started/use-scaffold-eth/advanced-permissions"
]
},
{
"type": "link",
"label": "LLM context",
"href": "https://docs.metamask.io/llms-smart-accounts-kit-full.txt"
},
"get-started/supported-networks"
]
},
Expand Down
24 changes: 12 additions & 12 deletions smart-accounts-kit/guides/configure-toolkit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
sidebar_label: Configure the toolkit
keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment]
keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment]
---

import Tabs from "@theme/Tabs";
Expand Down Expand Up @@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551

### Deploy a custom environment

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

This function requires a Viem [Public Client](https://viem.sh/docs/clients/public), [Wallet Client](https://viem.sh/docs/clients/wallet), and [Chain](https://viem.sh/docs/glossary/types#chain)
to deploy the contracts and resolve the `SmartAccountsEnvironment`.
Expand All @@ -146,9 +146,9 @@ Your wallet must have a sufficient native token balance to deploy the contracts.
```typescript
import { walletClient, publicClient } from "./config.ts";
import { sepolia as chain } from "viem/chains";
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";

const environment = await deployDeleGatorEnvironment(
const environment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand Down Expand Up @@ -182,16 +182,16 @@ export const publicClient = createPublicClient({
</TabItem>
</Tabs>

You can also override specific contracts when calling `deployDelegatorEnvironment`.
You can also override specific contracts when calling `deploySmartAccountsEnvironment`.
For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function.

```typescript
// The config.ts is the same as in the previous example.
import { walletClient, publicClient } from "./config.ts";
import { sepolia as chain } from "viem/chains";
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";

const environment = await deployDeleGatorEnvironment(
const environment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain,
Expand All @@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains";
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
import {
overrideDeployedEnvironment,
deployDeleGatorEnvironment
deploySmartAccountsEnvironment
} from "@metamask/smart-accounts-kit";

const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
walletClient,
publicClient,
chain
Expand All @@ -233,7 +233,7 @@ overrideDeployedEnvironment(
);
```

If you've already deployed the contracts using a different method, you can create a `DelegatorEnvironment` instance with the required contract addresses, and pass it to the function.
If you've already deployed the contracts using a different method, you can create a `SmartAccountsEnvironment` instance with the required contract addresses, and pass it to the function.

```typescript
// remove-start
Expand All @@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
import {
overrideDeployedEnvironment,
// remove-next-line
- deployDeleGatorEnvironment
- deploySmartAccountsEnvironment
} from "@metamask/smart-accounts-kit";

// remove-start
- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
- walletClient,
- publicClient,
- chain
Expand Down
Loading
Loading