diff --git a/delegation-toolkit/get-started/erc7715-quickstart.md b/delegation-toolkit/get-started/erc7715-quickstart.md index b7a7b4c172f..7ee8c0bbb9a 100644 --- a/delegation-toolkit/get-started/erc7715-quickstart.md +++ b/delegation-toolkit/get-started/erc7715-quickstart.md @@ -10,12 +10,22 @@ This quickstart demonstrates how to request and redeem ERC-7715 permissions. ## Prerequisites -- [Install and set up the Delegation Toolkit.](install.md) -- [Install MetaMask Flask 12.14.2 or later.](/snaps/get-started/install-flask) +- Install [Node.js](https://nodejs.org/en/blog/release/v18.18.0) v18 or later. +- Install [Yarn](https://yarnpkg.com/), + [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), or another package manager. +- [Install MetaMask Flask 12.14.2 or later](/snaps/get-started/install-flask). ## Steps -### 1. Set up a Wallet Client +### 1. Install the toolkit + +Install the [MetaMask Delegation Toolkit](https://www.npmjs.com/package/@metamask/delegation-toolkit): + +```bash npm2yarn +npm install @metamask/delegation-toolkit +``` + +### 2. Set up a Wallet Client Set up a [Viem Wallet Client](https://viem.sh/docs/clients/wallet) using Viem's `createWalletClient` function. This client will help you interact with MetaMask Flask. @@ -32,7 +42,7 @@ const walletClient = createWalletClient({ }).extend(erc7715ProviderActions()); ``` -### 2. Set up a Public Client +### 3. Set up a Public Client Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. This client will help you query the account state and interact with blockchain networks. @@ -47,7 +57,7 @@ const publicClient = createPublicClient({ }); ``` -### 3. Set up a session account +### 4. Set up a session account Set up a session account which can either be a smart account or an externally owned account (EOA) to request ERC-7715 permissions. This account is responsible @@ -74,7 +84,7 @@ const sessionAccount = await toMetaMaskSmartAccount({ }); ``` -### 4. Request ERC-7715 permissions +### 5. Request ERC-7715 permissions Request ERC-7715 permissions from the user. Currently, only the `native-token-stream` permission type is supported, which allows the dapp to stream @@ -106,7 +116,7 @@ const grantedPermissions = await walletClient.grantPermissions([{ }]); ``` -### 5. Set up a Bundler Client +### 6. Set up a Bundler Client Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function. This lets you use the bundler service @@ -127,7 +137,7 @@ const bundlerClient = createBundlerClient({ }).extend(erc7710BundlerActions()); ``` -### 6. Redeem ERC-7715 permissions +### 7. Redeem ERC-7715 permissions The session account can now [redeem the delegation](../experimental/erc-7710-redeem-delegations.md). The redeem transaction is sent to the `DelegationManager` contract, which validates the delegation and executes actions on the user's behalf. diff --git a/delegation-toolkit/get-started/install.md b/delegation-toolkit/get-started/install.md index f737e2572af..b4bfe181b1d 100644 --- a/delegation-toolkit/get-started/install.md +++ b/delegation-toolkit/get-started/install.md @@ -23,7 +23,7 @@ This page provides instructions to install and set up the MetaMask Delegation To ### 1. Install the toolkit -Install the [MetaMask Delegation Toolkit](https://github.com/MetaMask/delegation-toolkit) dependencies: +Install the [MetaMask Delegation Toolkit](https://www.npmjs.com/package/@metamask/delegation-toolkit): ```bash npm2yarn npm install @metamask/delegation-toolkit diff --git a/delegation-toolkit/get-started/smart-account-quickstart/eip7702.md b/delegation-toolkit/get-started/smart-account-quickstart/eip7702.md index a67fdf38a41..b4a02a521aa 100644 --- a/delegation-toolkit/get-started/smart-account-quickstart/eip7702.md +++ b/delegation-toolkit/get-started/smart-account-quickstart/eip7702.md @@ -11,12 +11,22 @@ abstraction, such as batch transactions, gas sponsorship, and [delegation capabi ## Prerequisites -- [Install and set up the Delegation Toolkit.](../install.md) -- [Install Viem.](https://viem.sh/) +- Install [Node.js](https://nodejs.org/en/blog/release/v18.18.0) v18 or later. +- Install [Yarn](https://yarnpkg.com/), + [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), or another package manager. +- [Install Viem](https://viem.sh/). ## Steps -### 1. Set up a Public Client +### 1. Install the toolkit + +Install the [MetaMask Delegation Toolkit](https://www.npmjs.com/package/@metamask/delegation-toolkit): + +```bash npm2yarn +npm install @metamask/delegation-toolkit +``` + +### 2. Set up a Public Client Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. This client will let the EOA query the account state and interact with blockchain network. @@ -31,7 +41,7 @@ const publicClient = createPublicClient({ }); ``` -### 2. Set up a Bundler Client +### 3. Set up a Bundler Client Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function. This lets you use the bundler service to estimate gas for user operations and submit transactions to the network. @@ -45,7 +55,7 @@ const bundlerClient = createBundlerClient({ }); ``` -### 3. Set up a Wallet Client +### 4. Set up a Wallet Client Set up [Viem Wallet Client](https://viem.sh/docs/clients/wallet) using Viem's `createWalletClient` function. This lets you sign and submit EIP-7702 authorization. @@ -64,7 +74,7 @@ export const walletClient = createWalletClient({ }); ``` -### 4. Authorize a 7702 delegation +### 5. Authorize a 7702 delegation Create an authorization to map the contract code to an EOA, and sign it using Viem's [`signAuthorization`](https://viem.sh/docs/eip7702/signAuthorization) action. The `signAuthorization` action @@ -92,7 +102,7 @@ const authorization = await walletClient.signAuthorization({ }); ``` -### 5. Submit the authorization +### 6. Submit the authorization Once you have signed an authorization, you can send an EIP-7702 transaction to set the EOA code. Since the authorization cannot be sent by itself, you can include it alongside a dummy transaction. @@ -107,7 +117,7 @@ const hash = await walletClient.sendTransaction({ }); ``` -### 6. Create a MetaMask smart account +### 7. Create a MetaMask smart account Create a smart account instance for the EOA and start leveraging the benefits of account abstraction. @@ -129,7 +139,7 @@ const smartAccount = await toMetaMaskSmartAccount({ }); ``` -### 7. Send a user operation +### 8. Send a user operation Send a user operation through the upgraded EOA, using Viem's [`sendUserOperation`](https://viem.sh/account-abstraction/actions/bundler/sendUserOperation) method. diff --git a/delegation-toolkit/get-started/smart-account-quickstart/index.md b/delegation-toolkit/get-started/smart-account-quickstart/index.md index 46b12562f8e..5a72c500f2f 100644 --- a/delegation-toolkit/get-started/smart-account-quickstart/index.md +++ b/delegation-toolkit/get-started/smart-account-quickstart/index.md @@ -9,11 +9,21 @@ You can get started quickly with [MetaMask Smart Accounts](../../concepts/smart- ## Prerequisites -[Install and set up the Delegation Toolkit.](../install.md) +- Install [Node.js](https://nodejs.org/en/blog/release/v18.18.0) v18 or later. +- Install [Yarn](https://yarnpkg.com/), + [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), or another package manager. ## Steps -### 1. Set up a Public Client +### 1. Install the toolkit + +Install the [MetaMask Delegation Toolkit](https://www.npmjs.com/package/@metamask/delegation-toolkit): + +```bash npm2yarn +npm install @metamask/delegation-toolkit +``` + +### 2. Set up a Public Client Set up a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. This client will let the smart account query the signer's account state and interact with blockchain network. @@ -27,7 +37,7 @@ const publicClient = createPublicClient({ }); ``` -### 2. Set up a Bundler Client +### 3. Set up a Bundler Client Set up a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundler) using Viem's `createBundlerClient` function. This lets you use the bundler service to estimate gas for user operations and submit transactions to the network. @@ -40,7 +50,7 @@ const bundlerClient = createBundlerClient({ }); ``` -### 3. Create a MetaMask smart account +### 4. Create a MetaMask smart account [Create a MetaMask smart account](../../guides/smart-accounts/create-smart-account.md) to send the first user operation. @@ -62,7 +72,7 @@ const smartAccount = await toMetaMaskSmartAccount({ }); ``` -### 4. Send a user operation +### 5. Send a user operation Send a user operation using Viem's [`sendUserOperation`](https://viem.sh/account-abstraction/actions/bundler/sendUserOperation) method. diff --git a/delegation-toolkit/guides/delegation/execute-on-smart-accounts-behalf.md b/delegation-toolkit/guides/delegation/execute-on-smart-accounts-behalf.md index 2e067e886d3..f0cccf3c9e6 100644 --- a/delegation-toolkit/guides/delegation/execute-on-smart-accounts-behalf.md +++ b/delegation-toolkit/guides/delegation/execute-on-smart-accounts-behalf.md @@ -122,9 +122,11 @@ export const delegateWalletClient = createWalletClient({ Create a [root delegation](../../concepts/delegation/index.md#delegation-types) from Alice to Bob. With a root delegation, Alice is delegating her own authority away, as opposed to *redelegating* permissions she received from a previous delegation. -Use the toolkit's [`createDelegation`](../../reference/api/delegation.md#createdelegation) method to create a root delegation. -This example passes an empty `caveats` array, which means Bob can perform any action on Alice's behalf. We recommend [restricting the delegation](restrict-delegation.md) by adding caveat enforcers. -For example, Alice can delegate the ability to spend her USDC to Bob, limiting the amount to 100 USDC. +Use the toolkit's [`createDelegation`](../../reference/api/delegation.md#createdelegation) method to create a root delegation. When creating +delegation, you need to configure the scope of the delegation to define the initial authority. + +This example uses the [`erc20TransferAmount`](./use-delegation-scopes/spending-limit#erc-20-transfer-scope) scope, allowing Alice to delegate to Bob the ability to spend her USDC, with a +specified limit on the total amount. :::warning Important @@ -135,10 +137,18 @@ Before creating a delegation, ensure that the delegator account (in this example ```typescript import { createDelegation } from "@metamask/delegation-toolkit" +// USDC address on Ethereum Sepolia. +const tokenAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"; + const delegation = createDelegation({ to: delegateSmartAccount.address, // This example uses a delegate smart account from: delegatorSmartAccount.address, - caveats: [], // Empty caveats array - we recommend adding appropriate restrictions. + environment: delegatorSmartAccount.environment + scope: { + type: "erc20TransferAmount", + tokenAddress, + maxAmount: 10000000n, + }, }) ``` @@ -226,3 +236,8 @@ const transactionHash = await delegateWalletClient.sendTransaction({ + +## Next steps + +- See [how to configure different scopes](use-delegation-scopes/index.md) to define the initial authority of a delegation. +- See [how to further refine the authority of a delegation](use-delegation-scopes/refine-scope.md) using caveat enforcers. \ No newline at end of file diff --git a/delegation-toolkit/guides/delegation/use-delegation-scopes/function-call.md b/delegation-toolkit/guides/delegation/use-delegation-scopes/function-call.md index e8279164d5e..91a4a6e1318 100644 --- a/delegation-toolkit/guides/delegation/use-delegation-scopes/function-call.md +++ b/delegation-toolkit/guides/delegation/use-delegation-scopes/function-call.md @@ -38,6 +38,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` diff --git a/delegation-toolkit/guides/delegation/use-delegation-scopes/ownership-transfer.md b/delegation-toolkit/guides/delegation/use-delegation-scopes/ownership-transfer.md index 215fd923dd0..e61e4c27d67 100644 --- a/delegation-toolkit/guides/delegation/use-delegation-scopes/ownership-transfer.md +++ b/delegation-toolkit/guides/delegation/use-delegation-scopes/ownership-transfer.md @@ -32,6 +32,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` diff --git a/delegation-toolkit/guides/delegation/use-delegation-scopes/spending-limit.md b/delegation-toolkit/guides/delegation/use-delegation-scopes/spending-limit.md index 43cc68cf6bf..150feeb3511 100644 --- a/delegation-toolkit/guides/delegation/use-delegation-scopes/spending-limit.md +++ b/delegation-toolkit/guides/delegation/use-delegation-scopes/spending-limit.md @@ -39,6 +39,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -67,6 +68,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -92,6 +94,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -113,6 +116,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -140,6 +144,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -167,6 +172,7 @@ const delegation = createDelegation({ }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` @@ -187,10 +193,12 @@ import { createDelegation } from "@metamask/delegation-toolkit"; const delegation = createDelegation({ scope: { type: "nativeTokenTransferAmount", - maxAmount: 1000000n, + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, }, to: delegateAccount, from: delegatorAccount, + environment: delegatorAccount.environment, }); ``` diff --git a/delegation-toolkit/reference/api/delegation.md b/delegation-toolkit/reference/api/delegation.md index 254eb890a60..906de3bf9ce 100644 --- a/delegation-toolkit/reference/api/delegation.md +++ b/delegation-toolkit/reference/api/delegation.md @@ -90,22 +90,30 @@ Creates a delegation with a specific delegate. | ---- | ---- | -------- | ----------- | | `from` | `Hex` | Yes | The address that is granting the delegation. | | `to` | `Hex` | Yes | The address to which the delegation is being granted. | -| `caveats` | `Caveats` | Yes | Caveats to restrict the authority being granted. | +| `scope` | `ScopeConfig` | Yes | The scope of the delegation that defines the initial authority. | +| `environment` | `DeleGatorEnvironment` | Yes | The environment used by the toolkit to define contract addresses for interacting with the Delegation Framework contracts. | +| `caveats` | `Caveats` | No | Caveats that further refine the authority granted by the `scope`. | | `parentDelegation` | `Delegation \| Hex` | No | The parent delegation or its corresponding hex to create a delegation chain. | | `salt` | `Hex` | No | The salt for generating the delegation hash. This helps prevent hash collisions when creating identical delegations. | ### Example ```typescript -import { createDelegation } from "@metamask/delegation-toolkit"; +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; const delegation = createDelegation({ // Address that is granting the delegation from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", // Address to which the delegation is being granted to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", - // Empty caveats array - we recommend adding appropriate restrictions - caveats: [], + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, + }, }); ``` @@ -118,7 +126,9 @@ Creates an open delegation that can be redeemed by any delegate. | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | | `from` | `Hex` | Yes | The address that is granting the delegation. | -| `caveats` | `Caveats` | Yes | Caveats to restrict the authority being granted. | +| `scope` | `ScopeConfig` | Yes | The scope of the delegation that defines the initial authority. | +| `environment` | `DeleGatorEnvironment` | Yes | The environment used by the toolkit to define contract addresses for interacting with the Delegation Framework contracts. | +| `caveats` | `Caveats` | No | Caveats that further refine the authority granted by the `scope`. | | `parentDelegation` | `Delegation \| Hex` | No | The parent delegation or its corresponding hex to create a delegation chain. | | `salt` | `Hex` | No | The salt for generating the delegation hash. This helps prevent hash collisions when creating identical delegations. | @@ -126,13 +136,19 @@ Creates an open delegation that can be redeemed by any delegate. ### Example ```typescript -import { createOpenDelegation } from "@metamask/delegation-toolkit"; +import { createOpenDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; const delegation = createOpenDelegation({ // Address that is granting the delegation from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", - // Empty caveats array - we recommend adding appropriate restrictions - caveats: [], + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, + }, }); ``` @@ -278,12 +294,17 @@ const disableDelegationData = DelegationManager.encode.disableDelegation({ ```ts import { createDelegation } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; export const delegation = createDelegation({ from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", - // Empty caveats array - we recommend adding appropriate restrictions - caveats: [], + environment: getDelegatorEnvironment(sepolia.id); + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, + }, }); ``` @@ -432,9 +453,8 @@ import { createWalletClient } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { sepolia } from "viem/chains"; -export const delegationManager = getDeleGatorEnvironment( - sepolia.id -).DelegationManager; +const environment = getDelegatorEnvironment(sepolia.id); +export const delegationManager = environment.DelegationManager; const account = privateKeyToAccount(delegateWallet as `0x${string}`); @@ -451,8 +471,12 @@ const delegate = "0x2FcB88EC2359fA635566E66415D31dD381CF5585"; export const delegation = createDelegation({ to: delegate, from: account.address, - // Empty caveats array - we recommend adding appropriate restrictions. - caveats: [], + environment, + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, + }, }); ``` diff --git a/delegation-toolkit/reference/api/smart-account.md b/delegation-toolkit/reference/api/smart-account.md index 7ef02dc7041..0d7ee8ee905 100644 --- a/delegation-toolkit/reference/api/smart-account.md +++ b/delegation-toolkit/reference/api/smart-account.md @@ -288,7 +288,7 @@ Signs the delegation and returns the delegation signature. ```ts -import { createDelegation } from "@metamask/delegation-toolkit"; +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; import { delegatorSmartAccount } from "./config.ts"; // The address to which the delegation is granted. It can be an EOA address, or @@ -298,8 +298,12 @@ const delegate = "0x2FcB88EC2359fA635566E66415D31dD381CF5585"; const delegation = createDelegation({ to: delegate, from: account.address, - // Empty caveats array - we recommend adding appropriate restrictions. - caveats: [], + environment: delegatorSmartAccount.environment, + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, + }, }); const signature = delegatorSmartAccount.signDelegation({ delegation }); diff --git a/delegation-toolkit/reference/delegation-scopes.md b/delegation-toolkit/reference/delegation-scopes.md index c316b52b871..25d15b36688 100644 --- a/delegation-toolkit/reference/delegation-scopes.md +++ b/delegation-toolkit/reference/delegation-scopes.md @@ -14,9 +14,22 @@ Learn [how to use delegation scopes](../guides/delegation/use-delegation-scopes/ Ensures a per-period limit for ERC-20 token transfers. At the start of each new period, the allowance resets. + +#### Parameters + +| Name | Type | Required | Description | +| ---------------- | --------- | -------- | ---------------------------------------------------------------- | +| `tokenAddress` | `Address` | Yes | The ERC-20 token contract address as a hex string. | +| `periodAmount` | `bigint` | Yes | The maximum amount of tokens that can be transferred per period. | +| `periodDuration` | `number` | Yes | The duration of each period in seconds. | +| `startDate` | `number` | Yes | The timestamp when the first period begins in seconds. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "erc20PeriodTransfer", @@ -25,8 +38,12 @@ const delegation = createDelegation({ periodDuration: 86400, startDate: 1743763600, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -36,9 +53,22 @@ Ensures a linear streaming transfer limit for ERC-20 tokens. Token transfers are blocked until the defined start timestamp. At the start, a specified initial amount is released, after which tokens accrue linearly at the configured rate, up to the maximum allowed amount. +#### Parameters + +| Name | Type | Required | Description | +| ----------------- | --------- | -------- | --------------------------------------------------------- | +| `tokenAddress` | `Address` | Yes | The ERC-20 token contract address. | +| `initialAmount` | `bigint` | Yes | The initial amount that can be transferred at start time. | +| `maxAmount` | `bigint` | Yes | The maximum total amount that can be unlocked. | +| `amountPerSecond` | `bigint` | Yes | The rate at which tokens accrue per second. | +| `startTime` | `number` | Yes | The start timestamp in seconds. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "erc20Streaming", @@ -48,8 +78,12 @@ const delegation = createDelegation({ maxAmount: 10000000n, startTime: 1703980800, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -58,35 +92,63 @@ const delegation = createDelegation({ Ensures that ERC-20 token transfers are limited to a predefined maximum amount. This scope is useful for setting simple, fixed transfer limits without any time-based or streaming conditions. +#### Parameters + +| Name | Type | Required | Description | +| -------------- | --------- | -------- | ----------------------------------------------------------------- | +| `tokenAddress` | `Address` | Yes | The ERC-20 token contract address. | +| `maxAmount` | `bigint` | Yes | The maximum amount of tokens that can be transferred by delegate. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "erc20TransferAmount", tokenAddress: "0xc11F3a8E5C7D16b75c9E2F60d26f5321C6Af5E92", maxAmount: 10000n, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` ### ERC-721 scope -Limits the delegation to ERC-721 token transfers only. +Limits the delegation to ERC-721 token (NFT) transfers only. + +#### Parameters + +| Name | Type | Required | Description | +| -------------- | --------- | -------- | ---------------------------------------------------------------------------- | +| `tokenAddress` | `Address` | Yes | The ERC-721 token contract address. | +| `tokenId` | `bigint` | Yes | The ID of the ERC-721 token that can be transferred by delegate. | #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "erc721Transfer", tokenAddress: "0x3fF528De37cd95b67845C1c55303e7685c72F319", tokenId: 1n, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -95,9 +157,20 @@ const delegation = createDelegation({ Ensures a per-period limit for native token transfers. At the start of each new period, the allowance resets. +#### Parameters + +| Name | Type | Required | Description | +| ---------------- | --------- | -------- | ---------------------------------------------------------------- | +| `periodAmount` | `bigint` | Yes | The maximum amount of tokens that can be transferred per period. | +| `periodDuration` | `number` | Yes | The duration of each period in seconds. | +| `startDate` | `number` | Yes | The timestamp when the first period begins in seconds. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "nativeTokenPeriodTransfer", @@ -105,8 +178,12 @@ const delegation = createDelegation({ periodDuration: 86400, startDate: 1743763600, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -116,9 +193,21 @@ Ensures a linear streaming transfer limit for native tokens. Token transfers are blocked until the defined start timestamp. At the start, a specified initial amount is released, after which tokens accrue linearly at the configured rate, up to the maximum allowed amount. +#### Parameters + +| Name | Type | Required | Description | +| ----------------- | --------- | -------- | --------------------------------------------------------- | +| `initialAmount` | `bigint` | Yes | The initial amount that can be transferred at start time. | +| `maxAmount` | `bigint` | Yes | The maximum total amount that can be unlocked. | +| `amountPerSecond` | `bigint` | Yes | The rate at which tokens accrue per second. | +| `startTime` | `number` | Yes | The start timestamp in seconds. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "nativeTokenStreaming", @@ -127,8 +216,12 @@ const delegation = createDelegation({ maxAmount: 10000000n, startTime: 1703980800, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -137,16 +230,30 @@ const delegation = createDelegation({ Ensures that native token transfers are limited to a predefined maximum amount. This scope is useful for setting simple, fixed transfer limits without any time based or streaming conditions. +#### Parameters + +| Name | Type | Required | Description | +| -------------- | --------- | -------- | ----------------------------------------------------------------- | +| `maxAmount` | `bigint` | Yes | The maximum amount of tokens that can be transferred by delegate. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "nativeTokenTransferAmount", - maxAmount: 1000000n, + // 0.001 ETH in wei format. + maxAmount: 1000000000000000n, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -154,19 +261,35 @@ const delegation = createDelegation({ Defines the specific methods, contract addresses, and calldata that are allowed for the delegation. +#### Parameters + +| Name | Type | Required | Description | +| ----------------- | -------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `targets` | `Address[]` | Yes | The list of addresses that the delegate is allowed to call. | +| `selectors` | `MethodSelector[]` | Yes | The list of method selectors that the delegate is allowed to call. The selector value can be 4-byte hex string, ABI function signature, or ABI function object. | +| `allowedCalldata` | `AllowedCalldataBuilderConfig[]` | No | The list of `calldata` that the delegate is allowed to call. | +| `exactCalldata` | `ExactCalldataBuilderConfig` | No | The `calldata` that the delegate is allowed to call. | + #### Example This example sets the delegation scope to allow the delegate to call the `approve` function on the USDC token contract. ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const delegation = createDelegation({ scope: { type: "functionCall", targets: ["0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"], // USDC address on Sepolia. selectors: ["approve(address, uint256)"] }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` @@ -174,9 +297,18 @@ const delegation = createDelegation({ Restricts a delegation to ownership transfer calls only. +#### Parameters + +| Name | Type | Required | Description | +| ----------------- | --------- | -------- | -----------------------------------------------------------------------| +| `contractAddress` | `Address` | Yes | The target contract address for which ownership transfers are allowed. | + #### Example ```typescript +import { createDelegation, getDelegatorEnvironment } from "@metamask/delegation-toolkit"; +import { sepolia } from "viem/chains"; + const contractAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" const delegation = createDelegation({ @@ -184,7 +316,11 @@ const delegation = createDelegation({ type: "ownershipTransfer", contractAddress, }, - to: delegateAccount, - from: delegatorAccount, + // Address that is granting the delegation + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + // Address to which the delegation is being granted + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + // Alternatively you can use environment property of MetaMask smart account. + environment: getDelegatorEnvironment(sepolia.id); }); ``` diff --git a/embedded-wallets/sdk/js/advanced/custom-authentication.mdx b/embedded-wallets/sdk/js/advanced/custom-authentication.mdx index eb8dc7cd649..6e5ad84b36a 100644 --- a/embedded-wallets/sdk/js/advanced/custom-authentication.mdx +++ b/embedded-wallets/sdk/js/advanced/custom-authentication.mdx @@ -42,7 +42,7 @@ You can only configure implicit login via modal, for JWT based logins, you need For the modal custom authentication, you need to pass the `modalConfig` object to the `Web3AuthOptions` object within the constructor. -> **Read more about the `modalConfig` object in the [Whitelabel](../whitelabel) section.** +> **Read more about the `modalConfig` object in the [Whitelabel](whitelabel.mdx) section.** ### Usage diff --git a/embedded-wallets/sdk/js/advanced/whitelabel.mdx b/embedded-wallets/sdk/js/advanced/whitelabel.mdx index eff2058ede6..80d43033f16 100644 --- a/embedded-wallets/sdk/js/advanced/whitelabel.mdx +++ b/embedded-wallets/sdk/js/advanced/whitelabel.mdx @@ -245,4 +245,4 @@ await web3auth.init() For complete control over the authentication interface, you can bypass the Web3Auth modal entirely and use the `connectTo` function. This allows you to create custom buttons that connect directly to specific auth providers. -See the [Custom Authentication](../custom-authentication) section for detailed implementation instructions. +See the [Custom Authentication](custom-authentication.mdx) section for detailed implementation instructions. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/custom-authentication.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/custom-authentication.mdx index 91eed851866..ad110f27ddd 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/custom-authentication.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/custom-authentication.mdx @@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem' This guide focuses specifically on migrating custom authentication configurations from Web3Auth v7 to v10. This covers the transition from "Verifiers" to "Connections" and "Grouped Connections". This -is a supplementary guide to the main [v7 to v10 migration guide](../README.mdx). +is a supplementary guide to the main [v7 to v10 migration guide](README.mdx). ## Overview @@ -180,5 +180,5 @@ client-side logic and provides a more robust way to manage authentication method ## Next Steps -Return to the main [v7 to v10 migration guide](../README) to continue with other +Return to the main [v7 to v10 migration guide](README.mdx) to continue with other migration aspects like method name changes and initialization updates. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/external-wallets.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/external-wallets.mdx index 5fb8cc67e57..db4693a737c 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/external-wallets.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/external-wallets.mdx @@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem' This guide focuses specifically on migrating external wallet adapter configurations from Web3Auth v7 to v10. This is a supplementary guide to the main -[v7 to v10 migration guide](../README.mdx). +[v7 to v10 migration guide](README.mdx). ## Overview @@ -88,5 +88,5 @@ No configuration needed - everything works out of the box! ## Next Steps -Return to the main [v7 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v7 to v10 migration guide](README.mdx) to continue with other migration aspects. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/wallet-services.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/wallet-services.mdx index db38eebb877..1c08064a1e0 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/wallet-services.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/wallet-services.mdx @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Wallet Services Migration Guide This guide focuses specifically on migrating Wallet Services functionality from Web3Auth v7 to v10. -This is a supplementary guide to the main [v7 to v10 migration guide](../README.mdx). +This is a supplementary guide to the main [v7 to v10 migration guide](README.mdx). ## Overview @@ -72,5 +72,5 @@ npm uninstall @web3auth/wallet-services-plugin ## Next Steps -Return to the main [v7 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v7 to v10 migration guide](README.mdx) to continue with other migration aspects. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/whitelabeling.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/whitelabeling.mdx index a2d893bda8a..475f3561889 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/whitelabeling.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v7-to-v10/whitelabeling.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Whitelabeling Migration Guide -This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v7 to v10. This is a supplementary guide to the main [v7 to v10 migration guide](../README.mdx). +This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v7 to v10. This is a supplementary guide to the main [v7 to v10 migration guide](README.mdx). ## Overview @@ -137,4 +137,4 @@ This shift centralizes UI control on the dashboard and simplifies client-side SD ## Next Steps -Return to the main [v7 to v10 migration guide](../README.mdx) to continue with other migration aspects like custom authentication and method name changes. +Return to the main [v7 to v10 migration guide](README.mdx) to continue with other migration aspects like custom authentication and method name changes. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/custom-authentication.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/custom-authentication.mdx index 5df8782b56a..ad3b2375ad6 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/custom-authentication.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/custom-authentication.mdx @@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem' This guide focuses specifically on migrating custom authentication configurations from Web3Auth v8 to v10. This covers the transition from "Verifiers" to "Connections" and "Grouped Connections". This -is a supplementary guide to the main [v8 to v10 migration guide](../README.mdx). +is a supplementary guide to the main [v8 to v10 migration guide](README.mdx). ## Overview @@ -176,5 +176,5 @@ client-side logic and provides a more robust way to manage authentication method ## Next Steps -Return to the main [v8 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v8 to v10 migration guide](README.mdx) to continue with other migration aspects like MFA configurations and method renames. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/external-wallets.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/external-wallets.mdx index 825b92d64a0..7dea9f66647 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/external-wallets.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/external-wallets.mdx @@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem' This guide focuses specifically on migrating external wallet adapter configurations from Web3Auth v8 to v10. This is a supplementary guide to the main -[v8 to v10 migration guide](../README.mdx). +[v8 to v10 migration guide](README.mdx). ## Overview @@ -85,5 +85,5 @@ This provides a better user experience with no configuration required from devel ## Next Steps -Return to the main [v8 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v8 to v10 migration guide](README.mdx) to continue with other migration aspects. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/wallet-services.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/wallet-services.mdx index 117427ba0fe..7bad7936b6f 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/wallet-services.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/wallet-services.mdx @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Wallet Services Migration Guide This guide focuses specifically on migrating Wallet Services functionality from Web3Auth v8 to v10. -This is a supplementary guide to the main [v8 to v10 migration guide](../README.mdx). +This is a supplementary guide to the main [v8 to v10 migration guide](README.mdx). ## Overview @@ -72,5 +72,5 @@ npm uninstall @web3auth/wallet-services-plugin ## Next Steps -Return to the main [v8 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v8 to v10 migration guide](README.mdx) to continue with other migration aspects. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/whitelabeling.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/whitelabeling.mdx index 5a6011cdf14..4f60c35e87e 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/whitelabeling.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v8-to-v10/whitelabeling.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Whitelabeling Migration Guide -This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v8 to v10. This is a supplementary guide to the main [v8 to v10 migration guide](../README.mdx). +This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v8 to v10. This is a supplementary guide to the main [v8 to v10 migration guide](README.mdx). ## Overview @@ -57,4 +57,4 @@ This shift centralizes UI control on the dashboard and simplifies client-side SD ## Next Steps -Return to the main [v8 to v10 migration guide](../README.mdx) to continue with other migration aspects like Smart Account functionality, custom authentication, and MFA configurations. +Return to the main [v8 to v10 migration guide](README.mdx) to continue with other migration aspects like Smart Account functionality, custom authentication, and MFA configurations. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/custom-authentication.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/custom-authentication.mdx index 2fc32eeeb40..7b6ee28722b 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/custom-authentication.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/custom-authentication.mdx @@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem' This guide focuses specifically on migrating custom authentication configurations from Web3Auth v9 to v10. This covers the transition from "Verifiers" to "Connections" and "Grouped Connections". This -is a supplementary guide to the main [v9 to v10 migration guide](../README.mdx). +is a supplementary guide to the main [v9 to v10 migration guide](README.mdx). ## Overview @@ -180,5 +180,5 @@ client-side logic and provides a more robust way to manage authentication method ## Next Steps -Return to the main [v9 to v10 migration guide](../README) to continue with other +Return to the main [v9 to v10 migration guide](README.mdx) to continue with other migration aspects like MFA configurations and method renames. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/smart-accounts.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/smart-accounts.mdx index 6192445f143..95c9ccb2a64 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/smart-accounts.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/smart-accounts.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Smart Account Migration Guide -This guide focuses specifically on migrating Smart Account configurations from Web3Auth v9 to v10. This is a supplementary guide to the main [v9 to v10 migration guide](../README.mdx). +This guide focuses specifically on migrating Smart Account configurations from Web3Auth v9 to v10. This is a supplementary guide to the main [v9 to v10 migration guide](README.mdx). ## Overview @@ -96,4 +96,4 @@ If you want to override the Smart Account provider, bundler, paymaster, or payma ## Next Steps -Return to the main [v9 to v10 migration guide](../README.mdx) to continue with other migration aspects like MFA configurations and method renames. +Return to the main [v9 to v10 migration guide](README.mdx) to continue with other migration aspects like MFA configurations and method renames. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/wallet-services.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/wallet-services.mdx index 4cf5b93b9e8..32fe015a11d 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/wallet-services.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/wallet-services.mdx @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Wallet Services Migration Guide This guide focuses specifically on migrating Wallet Services functionality from Web3Auth v9 to v10. -This is a supplementary guide to the main [v9 to v10 migration guide](../README.mdx). +This is a supplementary guide to the main [v9 to v10 migration guide](README.mdx). ## Overview @@ -72,5 +72,5 @@ npm uninstall @web3auth/wallet-services-plugin ## Next Steps -Return to the main [v9 to v10 migration guide](../README.mdx) to continue with other +Return to the main [v9 to v10 migration guide](README.mdx) to continue with other migration aspects. diff --git a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/whitelabeling.mdx b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/whitelabeling.mdx index 87cdfd02d9f..6671945a808 100644 --- a/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/whitelabeling.mdx +++ b/embedded-wallets/sdk/js/migration-guides/modal/v9-to-v10/whitelabeling.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem' # Web3Auth v10 Whitelabeling Migration Guide -This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v9 to v10. This is a supplementary guide to the main [v9 to v10 migration guide](../README.mdx). +This guide focuses specifically on migrating whitelabeling and UI customization configurations from Web3Auth v9 to v10. This is a supplementary guide to the main [v9 to v10 migration guide](README.mdx). ## Overview @@ -57,4 +57,4 @@ This shift centralizes UI control on the dashboard and simplifies client-side SD ## Next Steps -Return to the main [v9 to v10 migration guide](../README.mdx) to continue with other migration aspects like Smart Account functionality, custom authentication, and MFA configurations. +Return to the main [v9 to v10 migration guide](README.mdx) to continue with other migration aspects like Smart Account functionality, custom authentication, and MFA configurations. diff --git a/gator_versioned_docs/version-0.12.0/get-started/llm-context.md b/gator_versioned_docs/version-0.12.0/get-started/llm-context.md deleted file mode 100644 index 63ead6da5a5..00000000000 --- a/gator_versioned_docs/version-0.12.0/get-started/llm-context.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -sidebar_label: LLM context -description: Context about the MetaMask Delegation Toolkit that can be provided to an LLM. -sidebar_position: 4 -sidebar_class_name: hidden ---- - -# Delegation Toolkit LLM context - -This website contains an [`LLMs.txt`](/llms.txt) file that is intended for use by large language models (LLMs). -It provides information about the structure of the MetaMask developer documentation, -to facilitate better indexing, summarization, and understanding by LLMs. - -You can add this file to an LLM-based tool like [ChatGPT](https://chatgpt.com/) or [Cursor](https://docs.cursor.com/context/@-symbols/@-docs), -to provide detailed context about the MetaMask developer documentation. diff --git a/src/pages/tutorials/create-custom-caveat-enforcer.md b/src/pages/tutorials/create-custom-caveat-enforcer.md index c58a78d59ae..225b95f4904 100644 --- a/src/pages/tutorials/create-custom-caveat-enforcer.md +++ b/src/pages/tutorials/create-custom-caveat-enforcer.md @@ -10,7 +10,7 @@ author: MetaMask Developer Relations import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -This tutorial walks you through creating a custom [caveat enforcer](/delegation-toolkit/concepts/delegation/caveat-enforcers) and applying it to a [delegation](/delegation-toolkit/concepts/delegation/). +This tutorial walks you through creating a custom [caveat enforcer](/delegation-toolkit/development/concepts/delegation/caveat-enforcers) and applying it to a [delegation](/delegation-toolkit/concepts/delegation/). The MetaMask Delegation Toolkit includes [out-of-the-box caveat enforcers](/delegation-toolkit/reference/caveats) that define rules and restrictions for common use cases. For more specific control or other use cases, you can create custom caveat enforcers. @@ -19,7 +19,7 @@ In this tutorial, you'll create and apply a caveat enforcer that only allows a d ## Prerequisites - [Install and set up the Delegation Toolkit](/delegation-toolkit/get-started/install) in your project. -- [Configure the Delegation Toolkit.](/delegation-toolkit/guides/configure) +- [Configure the Delegation Toolkit.](/delegation-toolkit/development/guides/configure) - [Install Foundry and Forge.](https://getfoundry.sh/introduction/installation) - Get an [Infura API key](/developer-tools/dashboard/get-started/create-api) from the MetaMask Developer dashboard. - Have a MetaMask account with some Sepolia ETH to deploy your contract. @@ -92,7 +92,7 @@ The Forge CLI will display the address of the deployed caveat enforcer. ### 3. Apply the caveat enforcer Specify the address of the deployed `AfterTimestampEnforcer.sol` contract, add it to the caveat builder, and create a delegation. -Learn more about [applying caveats to a delegation](/delegation-toolkit/guides/delegation/restrict-delegation). +Learn more about [applying caveats to a delegation](/delegation-toolkit/development/guides/delegation/restrict-delegation). The following code snippet uses the custom caveat enforcer to create a delegation granting a 1,000,000 wei allowance that becomes spendable one hour after it is created: @@ -158,4 +158,4 @@ export const delegatorSmartAccount = await toMetaMaskSmartAccount({ You've successfully created, deployed, and applied a custom caveat enforcer! For production use cases, you might need to add additional caveats to restrict the delegation further. -Learn more about [caveat enforcers](/delegation-toolkit/concepts/delegation/caveat-enforcers). +Learn more about [caveat enforcers](/delegation-toolkit/development/concepts/delegation/caveat-enforcers). diff --git a/src/pages/tutorials/use-erc20-paymaster.md b/src/pages/tutorials/use-erc20-paymaster.md index df85028842a..cadec86debd 100644 --- a/src/pages/tutorials/use-erc20-paymaster.md +++ b/src/pages/tutorials/use-erc20-paymaster.md @@ -152,5 +152,5 @@ const userOperationHash = await bundlerClient.sendUserOperation({ ## Next steps -- See [Create a MetaMask smart account](/delegation-toolkit/development/guides/smart-accounts/create-smart-account) to learn more about smart account implementations. -- See [Send a gasless transaction](/delegation-toolkit/development/guides/smart-accounts/send-gasless-transaction) to learn how to use gasless paymaster. +- Learn more about [smart account implementations](/delegation-toolkit/development/guides/smart-accounts/create-smart-account). +- To sponsor gas for end users, see how to [send a gasless transaction](/delegation-toolkit/development/guides/smart-accounts/send-gasless-transaction). diff --git a/src/pages/tutorials/use-passkey-as-backup-signer.md b/src/pages/tutorials/use-passkey-as-backup-signer.md index 8cdc32ec01f..a60cd88d507 100644 --- a/src/pages/tutorials/use-passkey-as-backup-signer.md +++ b/src/pages/tutorials/use-passkey-as-backup-signer.md @@ -15,7 +15,7 @@ An externally owned account (EOA) uses the secp256k1 elliptic curve to generate In contrast, a passkey (WebAuthn credential) uses the secp256r1 (P-256) elliptic curve to generate key pairs and signatures. Passkeys eliminate the need for traditional seed phrases that are difficult to remember, enabling a more seamless and secure way for users to access their web3 wallets. -MetaMask Smart Accounts offer a [Hybrid implementation](/delegation-toolkit/concepts/smart-accounts#hybrid-smart-account), which supports signature validation for both secp256k1 and secp256r1 curves. +MetaMask Smart Accounts offer a [Hybrid implementation](/delegation-toolkit/concepts/smart-accounts/#hybrid-smart-account), which supports signature validation for both secp256k1 and secp256r1 curves. This allows you to add a passkey as a backup signer for your smart account. You can add passkeys during smart account creation or after the account has been deployed. @@ -25,8 +25,8 @@ This tutorial walks you through adding a passkey signer to an already deployed s - [Install and set up the Delegation Toolkit](/delegation-toolkit/get-started/install) in your project. - [Install Ox SDK](https://oxlib.sh/#installation). -- [Configure the Delegation Toolkit](/delegation-toolkit/guides/configure). -- [Create and deploy a Hybrid smart account,](/delegation-toolkit/guides/smart-accounts/create-smart-account) with a signatory from a private key. +- [Configure the Delegation Toolkit](/delegation-toolkit/development/guides/configure). +- [Create and deploy a Hybrid smart account,](/delegation-toolkit/development/guides/smart-accounts/create-smart-account) with a signatory from a private key. ## Steps @@ -61,7 +61,7 @@ const bundlerClient = createBundlerClient({ ### 3. Create a Hybrid smart account -Configure the same [Hybrid smart account](/delegation-toolkit/guides/smart-accounts/create-smart-account#create-a-hybrid-smart-account) that you created and deployed as a [prerequisite](#prerequisites). +Configure the same [Hybrid smart account](/delegation-toolkit/development/guides/smart-accounts/create-smart-account/#create-a-hybrid-smart-account) that you created and deployed as a [prerequisite](#prerequisites). The Hybrid implementation supports adding additional passkey signers. ```typescript @@ -163,5 +163,5 @@ const smartAccount = await toMetaMaskSmartAccount({ ## Next steps -- See [Create a MetaMask smart account](/delegation-toolkit/guides/smart-accounts/create-smart-account) to learn more about smart account implementations. -- See [Send a gasless transaction](/delegation-toolkit/guides/smart-accounts/send-gasless-transaction) to learn how to sponsor gas fees when adding a passkey as a backup signer. +- Learn more about [smart account implementations](/delegation-toolkit/development/guides/smart-accounts/create-smart-account). +- To sponsor gas fees when adding a passkey as a backup signer, see how to [send a gasless transaction](/delegation-toolkit/development/guides/smart-accounts/send-gasless-transaction).