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
12 changes: 12 additions & 0 deletions content/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions content/wallets/pages/recipes/smart-wallets-aave.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ slug: wallets/recipes/smart-wallets-aave

<Markdown src="../../shared/v4-code-banner.mdx" />

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

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

## Install packages
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
---

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

## 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.
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<Tip title="Most projects should use @alchemy/wallet-apis">
[`@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.
</Tip>

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
Expand Down
8 changes: 8 additions & 0 deletions content/wallets/pages/third-party/smart-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading