diff --git a/content/docs.yml b/content/docs.yml index a8c8256db..786123306 100644 --- a/content/docs.yml +++ b/content/docs.yml @@ -1075,6 +1075,18 @@ navigation: path: wallets/pages/authorization/smart-account-types/modular-account-v2/overview.mdx - page: Getting started path: wallets/pages/smart-contracts/modular-account-v2/getting-started.mdx + - section: Session keys + contents: + - page: What are session keys? + path: wallets/pages/smart-contracts/modular-account-v2/session-keys/index.mdx + - page: Adding session keys + path: wallets/pages/smart-contracts/modular-account-v2/session-keys/adding-session-keys.mdx + - page: Supported permissions + path: wallets/pages/smart-contracts/modular-account-v2/session-keys/session-key-permissions.mdx + - page: Using session keys + path: wallets/pages/smart-contracts/modular-account-v2/session-keys/using-session-keys.mdx + - page: Removing session keys + path: wallets/pages/smart-contracts/modular-account-v2/session-keys/removing-session-keys.mdx - section: Light Account contents: - page: Overview diff --git a/content/wallets/pages/authorization/policies/session-key-permissions.mdx b/content/wallets/pages/authorization/policies/session-key-permissions.mdx index 4133d5fa4..57a61ef61 100644 --- a/content/wallets/pages/authorization/policies/session-key-permissions.mdx +++ b/content/wallets/pages/authorization/policies/session-key-permissions.mdx @@ -38,7 +38,7 @@ Permissions are composable. You can apply multiple permissions to a single sessi Example: You could create a session key that: -* Only works between June 1–June 15 +* Expires after a configured time * Can call only one staking contract * Spend no more than 100 USDC diff --git a/content/wallets/pages/low-level-infra/third-party-infrastructure/chains.mdx b/content/wallets/pages/low-level-infra/third-party-infrastructure/chains.mdx index 03d3af7b3..33ceb27e6 100644 --- a/content/wallets/pages/low-level-infra/third-party-infrastructure/chains.mdx +++ b/content/wallets/pages/low-level-infra/third-party-infrastructure/chains.mdx @@ -46,4 +46,4 @@ const hash = await bundlerClient.sendUserOperation({ }); ``` -To add gas sponsorship via a third-party paymaster on this chain, see [Third Party Paymasters](/docs/wallets/low-level-infra/third-party-infrastructure/paymasters). +To add gas sponsorship via a third-party paymaster on this chain, configure viem's bundler client with that provider's [ERC-7677](https://eips.ethereum.org/EIPS/eip-7677) paymaster RPC. diff --git a/content/wallets/pages/recipes/smart-wallets-aave.mdx b/content/wallets/pages/recipes/smart-wallets-aave.mdx index 60cd2e35a..a5fad81c9 100644 --- a/content/wallets/pages/recipes/smart-wallets-aave.mdx +++ b/content/wallets/pages/recipes/smart-wallets-aave.mdx @@ -9,7 +9,7 @@ slug: wallets/recipes/smart-wallets-aave -Learn how to build DeFi applications that interact with Aave using Wallet APIs. This recipe covers supplying and withdrawing assets with both the [Core library](/docs/wallets/reference/aa-sdk/core) and the [Wallet APIs](/docs/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-request-account) for seamless user experiences. +Learn how to build DeFi applications that interact with Aave using Wallet APIs. This recipe covers supplying and withdrawing assets with both the [`@aa-sdk/core`](https://github.com/alchemyplatform/aa-sdk/tree/v4.x.x/aa-sdk/core) library and the [Wallet APIs](/docs/wallets/quickstart) for seamless user experiences. ## Prerequisites @@ -344,6 +344,6 @@ You can now interact with Aave protocol through smart wallets with sponsored gas ## Resources * [Aave V3 Documentation](https://docs.aave.com/developers/) -* [Alchemy Wallet APIs Quickstart](https://www.alchemy.com/docs/wallets/react/quickstart) +* [Alchemy Wallet APIs Quickstart](/docs/wallets/quickstart) * [Gas Manager Setup](https://www.alchemy.com/docs/setup-a-gas-manager-policy) * [Aave Contract Addresses](https://aave.com/docs/resources/addresses) diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/getting-started.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/getting-started.mdx index 2ddff5279..1a017a573 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/getting-started.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/getting-started.mdx @@ -7,7 +7,7 @@ slug: wallets/smart-contracts/modular-account-v2/getting-started Getting started with Modular Account V2 is straightforward. Below, you'll create a Modular Account V2 from a signer and send a transaction through viem's bundler client. Your MAv2 deploys onchain on the first user operation. - [`@alchemy/wallet-apis`](/docs/wallets/quickstart) already uses Modular Account V2 as its default smart account — `createSmartWalletClient` gives you MAv2 plus account creation, gas estimation, and the bundler client behind a single call. This page covers the lower-level path: instantiating MAv2 directly from `@alchemy/smart-accounts` and pairing it with viem's bundler client. Use it when you need fine-grained control over the wiring. + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) already uses Modular Account V2 as its default smart account — `createSmartWalletClient` gives you MAv2 plus account creation, gas estimation, and the bundler client behind a single call. This page covers the lower-level path: instantiating MAv2 directly from `@alchemy/smart-accounts` and pairing it with viem's bundler client. Use it when you need lower-level control over custom wiring. ## Install packages @@ -59,8 +59,6 @@ Two variants of Modular Account V2 are available: `default` and `7702`. * (Recommended) `default` provides the cheapest, most flexible smart wallet. * `7702` if you want EIP-7702 support — see the [EIP-7702 guide](/docs/wallets/transactions/using-eip-7702). -Want to enable social login methods? [Use Privy as your signer](/docs/wallets/wallet-integrations/privy). - ## Sending a transaction Pair the account with viem's bundler client (and `@alchemy/aa-infra`'s fee estimator) to submit user operations. diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/adding-session-keys.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/adding-session-keys.mdx index 23fd74761..202b9bb4b 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/adding-session-keys.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/adding-session-keys.mdx @@ -4,6 +4,10 @@ description: Adding session keys to your Modular Account V2 slug: wallets/smart-contracts/modular-account-v2/session-keys/adding-session-keys --- + + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) supports session keys through [`wallet_createSession`](/docs/wallets/reference/wallet-apis-session-keys/api) and the [`grantPermissions`](/docs/wallets/reference/wallet-apis-session-keys/sdk) SDK flow. This page covers the lower-level path: installing Modular Account V2 session-key validations directly with `@alchemy/smart-accounts` and viem's bundler client. Use it when you need lower-level control for custom onchain validation and permission wiring. + + To add a session key: 1) decide what permissions you want to grant the new key, and 2) call the [`installValidation`](#install-validation-parameters) function on the account. In v5 you do this by extending the bundler client with `installValidationActions`, encoding the install call via `encodeInstallValidation`, then sending it as a user operation. The bundler client returns a calldata hex; `sendUserOperation` wraps it in an `execute` call from the account. Scoped permissions are layered on as **hooks** that you pass into `installValidation`. Hooks can be combined — e.g. a session key that can only spend 10 USDC within the next 24 hours from the account. diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/index.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/index.mdx index f6795c819..5d82d075e 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/index.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/index.mdx @@ -4,6 +4,10 @@ description: Learn what session keys are, why they exist, and how they enable se slug: wallets/smart-contracts/modular-account-v2/session-keys --- + + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) supports session keys through [`wallet_createSession`](/docs/wallets/reference/wallet-apis-session-keys/api) and the [`grantPermissions`](/docs/wallets/reference/wallet-apis-session-keys/sdk) SDK flow. This section covers the lower-level path: managing Modular Account V2 session keys directly with `@alchemy/smart-accounts` and viem's bundler client. Use it when you need lower-level control for custom onchain validation and permission wiring. + + Session Keys allow you to add multiple signers to a smart account with scoped permissions that are validated onchain. This unlocks: * Multiple owners for accounts diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/removing-session-keys.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/removing-session-keys.mdx index c6450c4b0..633ab1528 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/removing-session-keys.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/removing-session-keys.mdx @@ -4,6 +4,10 @@ description: Removing session keys from your Modular Account V2 slug: wallets/smart-contracts/modular-account-v2/session-keys/removing-session-keys --- + + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) supports session keys through [`wallet_createSession`](/docs/wallets/reference/wallet-apis-session-keys/api) and the [`grantPermissions`](/docs/wallets/reference/wallet-apis-session-keys/sdk) SDK flow. This page covers the lower-level path: uninstalling Modular Account V2 session-key validations directly with `@alchemy/smart-accounts` and viem's bundler client. Use it when you need lower-level control for custom onchain validation and permission wiring. + + To remove a session key, extend the bundler client with `installValidationActions` and call `encodeUninstallValidation`. It returns calldata; send it as a user operation from the account. ```ts twoslash diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/session-key-permissions.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/session-key-permissions.mdx index b2c1bc653..e3c321fa3 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/session-key-permissions.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/session-key-permissions.mdx @@ -1,9 +1,13 @@ --- title: Supported permissions for session keys description: Explore the supported permission types you can apply to session keys to safely delegate access in smart accounts. -slug: wallets/smart-contracts/modular-account-v2/session-key-permissions +slug: wallets/smart-contracts/modular-account-v2/session-keys/session-key-permissions --- + + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) supports session keys through [`wallet_createSession`](/docs/wallets/reference/wallet-apis-session-keys/api) and the [`grantPermissions`](/docs/wallets/reference/wallet-apis-session-keys/sdk) SDK flow. This page covers the lower-level path: composing Modular Account V2 session-key permissions directly with `@alchemy/smart-accounts`. Use it when you need lower-level control for custom onchain validation and permission wiring. + + ## What permissions can you apply to session keys? Session keys work best when they are tightly scoped. Modular Account V2 gives you a flexible set of built-in permission types. These permissions are validated onchain, removing any dependency on an offchain engine and increasing security of users' accounts. @@ -38,7 +42,7 @@ Permissions are composable. You can apply multiple permissions to a single sessi Example: You could create a session key that: -* Only works between June 1–June 15 +* Expires after a configured time * Can call just one staking contract * Spend no more than 100 USDC diff --git a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/using-session-keys.mdx b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/using-session-keys.mdx index b14691d63..15e6ceb81 100644 --- a/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/using-session-keys.mdx +++ b/content/wallets/pages/smart-contracts/modular-account-v2/session-keys/using-session-keys.mdx @@ -4,6 +4,10 @@ description: Using session keys with your Modular Account V2 slug: wallets/smart-contracts/modular-account-v2/session-keys/using-session-keys --- + + [`@alchemy/wallet-apis`](/docs/wallets/quickstart) supports session keys through [`wallet_createSession`](/docs/wallets/reference/wallet-apis-session-keys/api) and the [`grantPermissions`](/docs/wallets/reference/wallet-apis-session-keys/sdk) SDK flow. This page covers the lower-level path: using Modular Account V2 session-key validations directly with `@alchemy/smart-accounts` and viem's bundler client. Use it when you need lower-level control for custom onchain validation and permission wiring. + + Once a session key is installed, you can use it by creating a second `ModularAccountV2` whose **owner** is the session key signer and whose `accountAddress` points to the original account. Pass the session key's `entityId` and global-validation flag via `signerEntity` — these were set when you called [`encodeInstallValidation`](/docs/wallets/smart-contracts/modular-account-v2/session-keys/adding-session-keys). ```ts twoslash diff --git a/content/wallets/pages/third-party/smart-contracts.mdx b/content/wallets/pages/third-party/smart-contracts.mdx index 74f819091..7053cafe9 100644 --- a/content/wallets/pages/third-party/smart-contracts.mdx +++ b/content/wallets/pages/third-party/smart-contracts.mdx @@ -56,3 +56,11 @@ The viem docs walk through a full custom example. Once you have a `SmartAccount` ### Why use the existing implementations? `@alchemy/smart-accounts` ships viem-compatible implementations of [Light Account](/docs/wallets/smart-contracts/other-accounts/light-account/getting-started), [Modular Account V1](/docs/wallets/reference/smart-accounts), and [Modular Account V2](/docs/wallets/smart-contracts/modular-account-v2/getting-started), plus the validation/permission builders for MAv2. If your use case fits one of those, you'll save a lot of custom-account boilerplate. + +### Using Alchemy smart accounts with third-party infrastructure + +If you want to keep Alchemy's smart account implementations while using non-Alchemy infrastructure, see the low-level infrastructure guides: + +* [Non-Alchemy chains](/docs/wallets/low-level-infra/third-party-infrastructure/chains) — run `@alchemy/smart-accounts` on a chain Alchemy doesn't support. +* [Third-party bundlers](/docs/wallets/low-level-infra/third-party-infrastructure/bundlers) — submit user operations through another bundler RPC. +* [Third-party paymasters](/docs/wallets/low-level-infra/third-party-infrastructure/paymasters) — sponsor user operations with a non-Alchemy paymaster.