Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
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,6 +182,24 @@ const execution = createExecution({
});
```

## `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");
```

## `deployDeleGatorEnvironment`

Deploys the Delegation Framework contracts to an EVM 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
12 changes: 6 additions & 6 deletions smart-accounts-kit/reference/delegation/index.md
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 @@ -195,7 +195,7 @@ Decodes an ABI-encoded hex string to an array of delegations.
### Example

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

const delegations = decodeDelegations("0x7f0db33d..c06aeeac");
```
Expand Down Expand Up @@ -321,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 Down Expand Up @@ -349,7 +349,7 @@ Encodes an array of delegations to an ABI-encoded hex string.
<TabItem value="example.ts">

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

const encodedDelegations = encodeDelegations([delegation]);
Expand All @@ -366,7 +366,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 Down
Loading