From 92ec65c21a7df7ed778c96e90124fba955c21ddb Mon Sep 17 00:00:00 2001 From: moldy Date: Thu, 1 Feb 2024 12:31:03 -0500 Subject: [PATCH 1/4] docs: begin refactoring the getting started sections --- site/.vitepress/config.ts | 2 +- site/.vitepress/sidebar/new.ts | 21 +++++++++++++++++-- site/{overview => }/faqs.md | 0 .../deploy-an-account.md} | 14 +++++-------- .../setup.md} | 2 +- site/index.md | 4 ++-- site/overview/introduction.md | 6 +++--- site/overview/why-account-kit.md | 2 +- site/packages/aa-accounts/index.md | 2 +- site/packages/aa-alchemy/index.md | 2 +- site/packages/aa-ethers/index.md | 2 +- site/packages/aa-signers/index.md | 2 +- .../sponsoring-gas/sponsoring-gas.md | 2 +- 13 files changed, 37 insertions(+), 24 deletions(-) rename site/{overview => }/faqs.md (100%) rename site/{smart-accounts/overview.md => getting-started/deploy-an-account.md} (81%) rename site/{overview/getting-started.md => getting-started/setup.md} (99%) diff --git a/site/.vitepress/config.ts b/site/.vitepress/config.ts index 7e960bf3d3..119d07dd81 100644 --- a/site/.vitepress/config.ts +++ b/site/.vitepress/config.ts @@ -11,7 +11,7 @@ export default defineConfig({ logo: "/kit-logo.svg", // https://vitepress.dev/reference/default-theme-config nav: [ - { text: "Docs", link: "/overview/getting-started" }, + { text: "Docs", link: "/getting-started/setup" }, { text: "Examples", link: "https://github.com/alchemyplatform/aa-sdk/tree/main/examples", diff --git a/site/.vitepress/sidebar/new.ts b/site/.vitepress/sidebar/new.ts index 2d792daf36..64054b942f 100644 --- a/site/.vitepress/sidebar/new.ts +++ b/site/.vitepress/sidebar/new.ts @@ -5,8 +5,25 @@ export const newSidebar: DefaultTheme.Sidebar = [ { text: "Getting Started", items: [ - { text: "Setup your project", link: "/overview/getting-started" }, - { text: "Deploy your first account", link: "/smart-accounts/overview" }, + { text: "Setup your project", link: "/getting-started/setup" }, + { + text: "Deploy your first account", + link: "/getting-started/deploy-an-account", + }, + // I'm leaving these here for now because I'm not sure if we still want them + // There's good content in here so we may want to keep it somewhere + { + text: "What is Account Kit?", + link: "/overview/introduction", + }, + { + text: "Why Account Kit?", + link: "/overview/why-account-kit", + }, + { + text: "FAQs", + link: "/faqs", + }, ], }, { diff --git a/site/overview/faqs.md b/site/faqs.md similarity index 100% rename from site/overview/faqs.md rename to site/faqs.md diff --git a/site/smart-accounts/overview.md b/site/getting-started/deploy-an-account.md similarity index 81% rename from site/smart-accounts/overview.md rename to site/getting-started/deploy-an-account.md index b04fbf7b11..d84051ee78 100644 --- a/site/smart-accounts/overview.md +++ b/site/getting-started/deploy-an-account.md @@ -3,7 +3,7 @@ outline: deep head: - - meta - property: og:title - content: Smart Accounts + content: Deploy your first account - - meta - name: description content: Follow this guide to understand the end-to-end process of integrating smart accounts in your applications with Account Kit. @@ -16,14 +16,9 @@ head: - - meta - name: twitter:description content: Follow this guide to understand the end-to-end process of integrating smart accounts in your applications with Account Kit. -prev: - text: Packages Overview - link: /package-overview -next: - text: Choosing a Smart Account --- -# Overview +# Deploy your first account In this guide we'll explain the end-to-end journey of integrating smart accounts in your applications with Account Kit. We'll cover the necessary steps such as creating an Alchemy account, selecting the right account and Signer and sending a User Operation. Additionally, we'll touch upon advanced functionalities like sponsoring gas, batching transactions and transferring ownership. @@ -33,8 +28,9 @@ Before diving into smart accounts, it's important to [set up your Alchemy accoun ## 2. Deploying a Smart Account -The next step is to select the right smart account implementation for your application. We recommend using `LightAccount`, which is a simple, secure, and cost-effective solution for most use cases. It supports features such as owner transfers, [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271) message signing, batched transactions and more. However, if you're looking for more advanced features, you can use your own account implementation. We'll cover both options in detail in the following sections: +The next step is to select the right smart account implementation for your application. We recommend using `ModularAccount`, [TODO: WILL HALP ME WITH YOUR WORDS]. We'll cover all the options in detail in the following sections: +- [Using Modular Accounts](/smart-accounts/accounts/guides/modular-account) - [Using Light Account](/smart-accounts/accounts/guides/light-account) - [Using your own account implementation](/smart-accounts/accounts/guides/using-your-own) @@ -44,7 +40,7 @@ The `LightAccount` implementation is not [ERC-6900](/smart-accounts/accounts/gui ## 3. Choosing a Signer -A Signer is the entity that signs transactions (User Operations) on behalf of the smart account. It can be an EOA, a custodial service, or a multi-party computation (MPC) service. We explain the different types of signers in detail in the [overview](signers/choosing-a-signer) section on choosing a Signer and offer integration guides in these docs, many of which use our `aa-signers` SDK. +A Signer is the entity that signs transactions (User Operations) on behalf of the smart account. It can be an EOA, a custodial service, or a multi-party computation (MPC) service. We explain the different types of signers in detail in the [overview](/smart-accounts/signers/choosing-a-signer) section on choosing a Signer and offer integration guides in these docs, many of which use our `aa-signers` SDK. At this point you should be able to integrate smart accounts in your application. However, there are a few advanced features that can help you improve the user experience and save on gas costs. Information about these can be found in the `Guides` section. diff --git a/site/overview/getting-started.md b/site/getting-started/setup.md similarity index 99% rename from site/overview/getting-started.md rename to site/getting-started/setup.md index b7978ef1ac..f675d98057 100644 --- a/site/overview/getting-started.md +++ b/site/getting-started/setup.md @@ -163,7 +163,7 @@ In this guide, we initialized an `AlchemyProvider` with the `aa-alchemy` package 1. To learn more about the different packages and their use cases, check out the [Packages Overview](/overview/package-overview) page. -2. To learn about the end-to-end process of integrating smart accounts in your applications, check out the section on [Smart Accounts](/smart-accounts/overview). +2. To learn about the end-to-end process of integrating smart accounts in your applications, check out the section on [Smart Accounts](/smart-accounts/). 3. To learn about the `owner` field on your smart account, check out the section on [Choosing a Signer](/smart-accounts/signers/choosing-a-signer) to own the smart account. diff --git a/site/index.md b/site/index.md index bc08d88952..1c3fe5f2a0 100644 --- a/site/index.md +++ b/site/index.md @@ -55,7 +55,7 @@ titleTemplate: :title Documentation Account Kit is a vertically integrated stack for building apps that support ERC-4337: smart accounts, Signer integrations, sponsoring gas, bundlers, and an SDK.
- +
- +
diff --git a/site/overview/introduction.md b/site/overview/introduction.md index 42ff7e143b..eb95f56e93 100644 --- a/site/overview/introduction.md +++ b/site/overview/introduction.md @@ -20,7 +20,7 @@ head: # What is Account Kit? -**Account Kit** is a framework to embed smart accounts in your web3 app, unlocking [powerful features](/overview/getting-started) like email/social login, gas sponsorship, batched transactions, and more. The `aa-sdk` makes it easy to integrate and deploy smart accounts, send user operations, and sponsor gas with just a few lines of code. +**Account Kit** is a framework to embed smart accounts in your web3 app, unlocking [powerful features](/getting-started/setup) like email/social login, gas sponsorship, batched transactions, and more. The `aa-sdk` makes it easy to integrate and deploy smart accounts, send user operations, and sponsor gas with just a few lines of code. ## What is the Account Kit stack? @@ -44,7 +44,7 @@ The SDK also implements an EIP-1193 provider interface to easily plug into any p The `aa-sdk` is modular at every layer of the stack and can be easily extended to fit your custom needs. You can plug in any [smart account](/smart-accounts/accounts/guides/using-your-own) implementation, [Signer](/smart-accounts/signers/choosing-a-signer), Gas Manager API, RPC provider. -Get started with `aa-sdk` in our [Getting Started guide](/overview/getting-started) or checkout the [open source repo](https://github.com/alchemyplatform/aa-sdk). +Get started with `aa-sdk` in our [Getting Started guide](/getting-started/setup) or checkout the [open source repo](https://github.com/alchemyplatform/aa-sdk). ### Light Account @@ -84,4 +84,4 @@ Check out the open source code in our affectionately named [Rundler github repo] ## Start building with Account Kit -Account Kit was designed from the ground up to make account abstraction easy. It’s built on top of industry-leading infrastructure that powers applications at massive scale from Opensea to Shopify. Start integrating Account Kit today in the [Getting Started guide](/overview/getting-started). +Account Kit was designed from the ground up to make account abstraction easy. It’s built on top of industry-leading infrastructure that powers applications at massive scale from Opensea to Shopify. Start integrating Account Kit today in the [Getting Started guide](/getting-started/setup). diff --git a/site/overview/why-account-kit.md b/site/overview/why-account-kit.md index a3c77bbf49..cdd982f88c 100644 --- a/site/overview/why-account-kit.md +++ b/site/overview/why-account-kit.md @@ -107,4 +107,4 @@ We built Account Kit from the ground up to be reliable, scalable, and developer- We have years of experience as the leading web3 developer platform powering customers from Opensea to Shopify, and brought all that expertise to bear in Account Kit. -Get started with Account Kit on the next page: [Getting Started](/overview/getting-started). +Get started with Account Kit on the next page: [Getting Started](/getting-started/setup). diff --git a/site/packages/aa-accounts/index.md b/site/packages/aa-accounts/index.md index 26170f3a7d..54ec17507a 100644 --- a/site/packages/aa-accounts/index.md +++ b/site/packages/aa-accounts/index.md @@ -23,7 +23,7 @@ This package contains various implementations of the `BaseSmartContractAccount` ## Getting started -If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the accounts. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/overview/getting-started) docs to get started. +If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the accounts. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/getting-started/setup) docs to get started. ::: code-group diff --git a/site/packages/aa-alchemy/index.md b/site/packages/aa-alchemy/index.md index b24d592832..6c591ddf04 100644 --- a/site/packages/aa-alchemy/index.md +++ b/site/packages/aa-alchemy/index.md @@ -23,7 +23,7 @@ This package contains the `AlchemySmartAccountClient`, an extension of the `Smar ## Getting started -If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `AlchemySmartAccountClient`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/overview/getting-started) docs to get started. +If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `AlchemySmartAccountClient`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/getting-started/setup) docs to get started. ::: code-group diff --git a/site/packages/aa-ethers/index.md b/site/packages/aa-ethers/index.md index 3279635e5c..9b99f078d2 100644 --- a/site/packages/aa-ethers/index.md +++ b/site/packages/aa-ethers/index.md @@ -27,7 +27,7 @@ This repo is community maintained and we welcome contributions! ## Getting started -If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `EthersProviderAdapter` and `AccountSigner`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/overview/getting-started) docs to get started. +If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `EthersProviderAdapter` and `AccountSigner`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/getting-started/setup) docs to get started. ::: code-group diff --git a/site/packages/aa-signers/index.md b/site/packages/aa-signers/index.md index 98f69f6950..0f177d6a24 100644 --- a/site/packages/aa-signers/index.md +++ b/site/packages/aa-signers/index.md @@ -23,7 +23,7 @@ This package contains various implementations of the `SmartAccountSigner` and `S ## Getting started -If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the signers. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/overview/getting-started) docs to get started. +If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the signers. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](/getting-started/setup) docs to get started. ::: code-group diff --git a/site/tutorials/sponsoring-gas/sponsoring-gas.md b/site/tutorials/sponsoring-gas/sponsoring-gas.md index 5c33b8b525..e3b27a6d9f 100644 --- a/site/tutorials/sponsoring-gas/sponsoring-gas.md +++ b/site/tutorials/sponsoring-gas/sponsoring-gas.md @@ -24,7 +24,7 @@ Gas fees are a significant barrier to entry for new user of your app. With Accou ## How to Sponsor Gas -After [installing `aa-sdk`](/overview/getting-started#install-the-packages) in your project, follow these steps to sponsor gas. +After [installing `aa-sdk`](/getting-started/setup#install-the-packages) in your project, follow these steps to sponsor gas. ### 1. Set Up the Provider From 3d4c70774fb30091b1c7c0bd6e52a72edea6b60f Mon Sep 17 00:00:00 2001 From: moldy Date: Thu, 1 Feb 2024 12:52:17 -0500 Subject: [PATCH 2/4] docs: begin refactoring the light account docs sections --- site/.vitepress/sidebar/new.ts | 8 +-- site/getting-started/deploy-an-account.md | 6 +-- site/glossary/terms.md | 6 +-- site/overview/introduction.md | 4 +- .../accounts/guides/using-your-own.md | 2 +- .../choosing-a-smart-account.md => index.md} | 6 +-- .../light-account/deployments.md | 32 ++++++++++++ .../light-account/getting-started.md | 49 +++++++++++++++++++ .../index.md} | 16 ++---- .../index.md} | 0 .../signers/choosing-a-signer.md | 4 +- 11 files changed, 105 insertions(+), 28 deletions(-) rename site/smart-accounts/{accounts/choosing-a-smart-account.md => index.md} (76%) create mode 100644 site/smart-accounts/light-account/deployments.md create mode 100644 site/smart-accounts/light-account/getting-started.md rename site/smart-accounts/{accounts/guides/light-account.md => light-account/index.md} (78%) rename site/smart-accounts/{accounts/guides/modular-account.md => modular-account/index.md} (100%) diff --git a/site/.vitepress/sidebar/new.ts b/site/.vitepress/sidebar/new.ts index 64054b942f..5a38228fcd 100644 --- a/site/.vitepress/sidebar/new.ts +++ b/site/.vitepress/sidebar/new.ts @@ -29,10 +29,11 @@ export const newSidebar: DefaultTheme.Sidebar = [ { text: "Choosing a Smart Account", items: [ - { text: "Introduction", link: "/" }, + { text: "Introduction", link: "/smart-accounts/" }, { text: "Modular Account", collapsed: false, + base: "/smart-accounts/modular-account", items: [ { text: "Introduction", link: "/" }, { text: "Getting started", link: "/" }, @@ -42,10 +43,11 @@ export const newSidebar: DefaultTheme.Sidebar = [ { text: "Light Account", collapsed: true, + base: "/smart-accounts/light-account", items: [ { text: "Introduction", link: "/" }, - { text: "Getting started", link: "/" }, - { text: "Deployments", link: "/" }, + { text: "Getting started", link: "/getting-started" }, + { text: "Deployments", link: "/deployments" }, ], }, { diff --git a/site/getting-started/deploy-an-account.md b/site/getting-started/deploy-an-account.md index d84051ee78..08d8bde726 100644 --- a/site/getting-started/deploy-an-account.md +++ b/site/getting-started/deploy-an-account.md @@ -30,12 +30,12 @@ Before diving into smart accounts, it's important to [set up your Alchemy accoun The next step is to select the right smart account implementation for your application. We recommend using `ModularAccount`, [TODO: WILL HALP ME WITH YOUR WORDS]. We'll cover all the options in detail in the following sections: -- [Using Modular Accounts](/smart-accounts/accounts/guides/modular-account) -- [Using Light Account](/smart-accounts/accounts/guides/light-account) +- [Using Modular Accounts](/smart-accounts/modular-account/) +- [Using Light Account](/smart-accounts/light-account/) - [Using your own account implementation](/smart-accounts/accounts/guides/using-your-own) ::: tip Note -The `LightAccount` implementation is not [ERC-6900](/smart-accounts/accounts/guides/modular-account) compliant. The `ModularAccount` implementation is launching later this year and will be EIP-6900 compatible. However, `LightAccount` is forward-compatible with `ModularAccount` and can be upgraded to it in the future. +The `LightAccount` implementation is not [ERC-6900](/smart-accounts/modular-account/) compliant. The `ModularAccount` implementation is launching later this year and will be EIP-6900 compatible. However, `LightAccount` is forward-compatible with `ModularAccount` and can be upgraded to it in the future. ::: ## 3. Choosing a Signer diff --git a/site/glossary/terms.md b/site/glossary/terms.md index 16da04b371..9935ed7cb0 100644 --- a/site/glossary/terms.md +++ b/site/glossary/terms.md @@ -50,11 +50,11 @@ Alchemy’s implementation of a [Paymaster](https://www.alchemy.com/overviews/wh ## Light Account -[Light Account](https://accountkit.alchemy.com/smart-accounts/accounts/guides/light-account.html) is a production-ready [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) [smart account](#smart-account) implementation developed by Alchemy. It builds on top of Ethereum Foundation’s [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) to add key improvements such as support for ownership transfer, ERC-1271 signature support, and gas optimizations. It is [audited by Quantstamp](https://github.com/alchemyplatform/light-account/blob/main/Quantstamp-Audit.pdf). +[Light Account](https://accountkit.alchemy.com/smart-accounts/light-account/.html) is a production-ready [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) [smart account](#smart-account) implementation developed by Alchemy. It builds on top of Ethereum Foundation’s [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) to add key improvements such as support for ownership transfer, ERC-1271 signature support, and gas optimizations. It is [audited by Quantstamp](https://github.com/alchemyplatform/light-account/blob/main/Quantstamp-Audit.pdf). ## Modular Account -A type of smart account enabled by the [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900) standard and characterized by its [modular structure](https://accountkit.alchemy.com/smart-accounts/accounts/guides/modular-account.html). This structure segments different functionalities of the account into distinct, independently upgradeable modules or plugins. Each plugin can have specific functions such as validation, execution, or hooks, enabling the smart account to extend its capabilities or modify its behavior without altering the core account logic. Modular accounts enhance flexibility, upgradeability, and interoperability of [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart accounts. +A type of smart account enabled by the [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900) standard and characterized by its [modular structure](https://accountkit.alchemy.com/smart-accounts/modular-account/.html). This structure segments different functionalities of the account into distinct, independently upgradeable modules or plugins. Each plugin can have specific functions such as validation, execution, or hooks, enabling the smart account to extend its capabilities or modify its behavior without altering the core account logic. Modular accounts enhance flexibility, upgradeability, and interoperability of [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart accounts. ## Plugin @@ -75,7 +75,7 @@ A service or application that manages the private key and signs `UserOperation`s ## Smart Account -A [smart account](https://accountkit.alchemy.com/smart-accounts/accounts/choosing-a-smart-account.html#what-s-a-smart-account) is an individual on-chain account located at a public address where an ERC-4337 smart contract account is deployed. This address is controlled by one or more owners of the smart contract account. The [aa-sdk](https://github.com/alchemyplatform/aa-sdk) supports different smart account implementations such as [Light Account](https://accountkit.alchemy.com/smart-accounts/accounts/guides/light-account.html), [Simple Account](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) and [Modular Account](https://accountkit.alchemy.com/smart-accounts/accounts/guides/modular-account.html) (coming soon). You can also [add add your own account implementation in aa-sdk](https://accountkit.alchemy.com/smart-accounts/accounts/contributing.html). +A [smart account](https://accountkit.alchemy.com/smart-accounts/.html#what-s-a-smart-account) is an individual on-chain account located at a public address where an ERC-4337 smart contract account is deployed. This address is controlled by one or more owners of the smart contract account. The [aa-sdk](https://github.com/alchemyplatform/aa-sdk) supports different smart account implementations such as [Light Account](https://accountkit.alchemy.com/smart-accounts/light-account/.html), [Simple Account](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) and [Modular Account](https://accountkit.alchemy.com/smart-accounts/modular-account/.html) (coming soon). You can also [add add your own account implementation in aa-sdk](https://accountkit.alchemy.com/smart-accounts/accounts/contributing.html). ## `UserOperation` diff --git a/site/overview/introduction.md b/site/overview/introduction.md index eb95f56e93..de15845156 100644 --- a/site/overview/introduction.md +++ b/site/overview/introduction.md @@ -52,7 +52,7 @@ Get started with `aa-sdk` in our [Getting Started guide](/getting-started/setup) We started with the Ethereum Foundation’s canonical [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) and added key improvements for production app development: -- Significantly [reduced gas costs](/smart-accounts/accounts/choosing-a-smart-account#benchmarks) +- Significantly [reduced gas costs](/smart-accounts/#benchmarks) - ERC-1271 signature support to ensure users can sign messages, such as on Opensea - Ownership transfer so that users won’t get locked into a single Signer @@ -60,7 +60,7 @@ We started with the Ethereum Foundation’s canonical [SimpleAccount](https://gi `LightAccount` is forward-compatible with [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900), a new standard for **modular** smart accounts. Once we stabilize the ERC with the [community](https://ethereum-magicians.org/t/erc-6900-modular-smart-contract-accounts-and-plugins/13885/35) and publish a reference implementation, we will release an optional upgrade for `LightAccount` to upgrade to modular EIP-6900 compliant accounts. [Join the discussion](https://ethereum-magicians.org/t/erc-6900-modular-smart-contract-accounts-and-plugins/13885/35) on ERC-6900! -To learn how to deploy a `LightAccount`, see [Light Account](/smart-accounts/accounts/guides/light-account). +To learn how to deploy a `LightAccount`, see [Light Account](/smart-accounts/light-account/). ### Signers diff --git a/site/smart-accounts/accounts/guides/using-your-own.md b/site/smart-accounts/accounts/guides/using-your-own.md index 6033bb4ff4..6296ba0cf1 100644 --- a/site/smart-accounts/accounts/guides/using-your-own.md +++ b/site/smart-accounts/accounts/guides/using-your-own.md @@ -50,7 +50,7 @@ The `BaseSmartContractAccount` class also exposes some additional implementation ## `LightSmartContractAccount` as an Example -We have built an extension of the eth-infinitism `SimpleAccount` called [LightAccount.sol](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol). You can learn more about Light Account in the [Light Account documentation](/smart-accounts/accounts/guides/light-account). +We have built an extension of the eth-infinitism `SimpleAccount` called [LightAccount.sol](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol). You can learn more about Light Account in the [Light Account documentation](/smart-accounts/light-account/). We provide an implementation of `ISmartContractAccount` that works with `LightAccount.sol` which can be used as an example of how to implement your own Smart Contract Account: ::: details LightSmartContractAccount diff --git a/site/smart-accounts/accounts/choosing-a-smart-account.md b/site/smart-accounts/index.md similarity index 76% rename from site/smart-accounts/accounts/choosing-a-smart-account.md rename to site/smart-accounts/index.md index 468a3c3ffb..5ae37ee0ab 100644 --- a/site/smart-accounts/accounts/choosing-a-smart-account.md +++ b/site/smart-accounts/index.md @@ -28,19 +28,19 @@ next: ## What's a Smart Account? -A smart account is an [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart account. You can use it to manage assets, execute transactions (known as `userOperations` or `userOps`), and more. There are many different implementations of a smart account, including our [Light Account](/smart-accounts/accounts/guides/light-account). +A smart account is an [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart account. You can use it to manage assets, execute transactions (known as `userOperations` or `userOps`), and more. There are many different implementations of a smart account, including our [Light Account](/smart-accounts/light-account/). ## Light Account Account Kit provides a default smart account called `LightAccount`. -[Light Account](/smart-accounts/accounts/guides/light-account) is a secure, audited, gas-optimized, ERC-4337 compatible smart account implementation. It comes equipped with features like owner transfers, [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271) message signing, and batched transactions. It's also [open source](https://github.com/alchemyplatform/light-account)! +[Light Account](/smart-accounts/light-account/) is a secure, audited, gas-optimized, ERC-4337 compatible smart account implementation. It comes equipped with features like owner transfers, [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271) message signing, and batched transactions. It's also [open source](https://github.com/alchemyplatform/light-account)! For most applications, we recommend using Light Account. It is [deployed](/smart-accounts/accounts/deployment-addresses) on Ethereum, Optimism, Arbitrum, Polygon, Base, and the respective testnets. ## Modular Account (coming soon) -We are authoring a standard for modular smart accounts called [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900). Soon we will release an ERC-6900 compatible [Modular Account](/smart-accounts/accounts/guides/modular-account). This will be an optional upgrade from Light Account to unlock an ecosystem of plugins for your smart account stack. +We are authoring a standard for modular smart accounts called [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900). Soon we will release an ERC-6900 compatible [Modular Account](/smart-accounts/modular-account/). This will be an optional upgrade from Light Account to unlock an ecosystem of plugins for your smart account stack. ## Use Your Own Account diff --git a/site/smart-accounts/light-account/deployments.md b/site/smart-accounts/light-account/deployments.md new file mode 100644 index 0000000000..49d1bfc50c --- /dev/null +++ b/site/smart-accounts/light-account/deployments.md @@ -0,0 +1,32 @@ +--- +outline: deep +head: + - - meta + - property: og:title + content: Light Account • Deployment Addresses + - - meta + - name: description + content: Deployment Addresses for Light Account + - - meta + - property: og:description + content: Deployment Addresses for Light Account +--- + +# [Deployment Addresses](https://github.com/alchemyplatform/light-account/blob/v1.1.0/Deployments.md) + +The following tables list the deployed factory and account implementation contract addresses for `LightAccount` on different chains: + +| Chain | Factory Address | Account Implementation | +| ---------------- | ------------------------------------------ | ------------------------------------------ | +| Eth Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Eth Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Eth Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Polygon Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Polygon Mumbai | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Optimism | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Optimism Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Base | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Base Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | diff --git a/site/smart-accounts/light-account/getting-started.md b/site/smart-accounts/light-account/getting-started.md new file mode 100644 index 0000000000..81d46ad2c1 --- /dev/null +++ b/site/smart-accounts/light-account/getting-started.md @@ -0,0 +1,49 @@ +--- +outline: deep +head: + - - meta + - property: og:title + content: Light Account • Getting Started + - - meta + - name: description + content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + - - meta + - property: og:description + content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + - - meta + - name: twitter:title + content: Light Account + - - meta + - name: twitter:description + content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. +--- + +# Getting started + +Getting started with Light Account is really simple! Simply create a `SmartAccountClient` and an instance of `LightAccount` and you're ready to go. + +## Import + +::: code-group + +```ts [aa-alchemy] +import { createLightAccountAlchemyClient } from "@alchemy/aa-alchemy"; +``` + +```ts [aa-core] +import { createLightAccount } from "@alchemy/aa-accounts"; +import { createSmartAccountClient } from "@alchemy/aa-core"; +``` + +::: + +## Usage + +The code snippet below demonstrates how to use Light Account with Account Kit. It creates a Light Account and sends a `UserOperation` from it: +::: code-group + +<<< @/snippets/aa-alchemy/light-account.ts [aa-alchemy] + +<<< @/snippets/aa-core/smartAccountClient.ts [aa-core] + +::: code-group diff --git a/site/smart-accounts/accounts/guides/light-account.md b/site/smart-accounts/light-account/index.md similarity index 78% rename from site/smart-accounts/accounts/guides/light-account.md rename to site/smart-accounts/light-account/index.md index 5f8655b79f..11ed3d9f6a 100644 --- a/site/smart-accounts/accounts/guides/light-account.md +++ b/site/smart-accounts/light-account/index.md @@ -3,19 +3,19 @@ outline: deep head: - - meta - property: og:title - content: Light Account Smart Contract + content: Light Account - - meta - name: description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: What is Light Account? - - meta - property: og:description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: What is Light Account? - - meta - name: twitter:title content: Light Account - - meta - name: twitter:description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: What is Light Account? --- # Light Account @@ -48,13 +48,7 @@ Light Account has been audited by Quantstamp. You can find the audit report [her ### Modular 6900 Accounts (Coming Soon) -We're pioneering the future of modular smart accounts with [EIP-6900](https://www.alchemy.com/blog/account-abstraction-erc-6900/?a=ak-docs). We're developing a [Modular Account](./modular-account.md) to support EIP-6900 coming soon. Light Account is designed with that future in mind. It is forward-compatible with EIP-6900 so you can upgrade it to 6900-compatible account once the Modular Account is ready. - -## Using Light Account - -The code snippet below demonstrates how to use Light Account with Account Kit. It creates a Light Account and sends a `UserOperation` from it: - -<<< @/snippets/aa-alchemy/light-account.ts +We're pioneering the future of modular smart accounts with [EIP-6900](https://www.alchemy.com/blog/account-abstraction-erc-6900/?a=ak-docs). We're developing a [Modular Account](../modular-account/) to support EIP-6900 coming soon. Light Account is designed with that future in mind. It is forward-compatible with EIP-6900 so you can upgrade it to 6900-compatible account once the Modular Account is ready. ## Developer Links diff --git a/site/smart-accounts/accounts/guides/modular-account.md b/site/smart-accounts/modular-account/index.md similarity index 100% rename from site/smart-accounts/accounts/guides/modular-account.md rename to site/smart-accounts/modular-account/index.md diff --git a/site/smart-accounts/signers/choosing-a-signer.md b/site/smart-accounts/signers/choosing-a-signer.md index bdc9d5bcf4..fb9d63f7ce 100644 --- a/site/smart-accounts/signers/choosing-a-signer.md +++ b/site/smart-accounts/signers/choosing-a-signer.md @@ -18,7 +18,7 @@ head: content: Explore Account Kit integration guides for signers including Magic.Link, Privy, Web3Auth, EOAs, and many more! prev: text: Smart Accounts - link: /smart-accounts/accounts/choosing-a-smart-account + link: /smart-accounts/ next: text: How to Send a User Operation link: /tutorials/send-user-operation @@ -28,7 +28,7 @@ next: A **Signer** is a service (e.g. Magic or Turnkey) or application (e.g. MetaMask) that manages the private key and signs operations. Most web3 users today use an [Externally Owned Account (EOA)](https://ethereum.org/en/developers/docs/accounts/#externally-owned-accounts-and-key-pairs) with a self-custodial Signer such as MetaMask to manage the private key. -With Account Kit, you will deploy a **smart account** for each user instead of an EOA wallet. This smart account stores the user’s assets (e.g. tokens or NFTs). The default smart account in Account Kit is called [`LightAccount`](/smart-accounts/accounts/guides/light-account) and it uses a typical single-owner architecture. +With Account Kit, you will deploy a **smart account** for each user instead of an EOA wallet. This smart account stores the user’s assets (e.g. tokens or NFTs). The default smart account in Account Kit is called [`LightAccount`](/smart-accounts/light-account/) and it uses a typical single-owner architecture. The smart account is controlled by an **Owner** address. The smart account will only execute a transaction if it was signed by the owner’s private key. From 24cf8cdd81b224f70f776e21d69aa9d443db56f0 Mon Sep 17 00:00:00 2001 From: moldy Date: Thu, 1 Feb 2024 13:17:59 -0500 Subject: [PATCH 3/4] docs: add docs for using and contributing custom accounts --- site/.vitepress/sidebar/new.ts | 7 +- site/getting-started/deploy-an-account.md | 2 +- site/overview/introduction.md | 2 +- site/overview/package-overview.md | 4 +- .../accounts/guides/using-your-own.md | 66 ------------------- .../{accounts => custom}/contributing.md | 45 +------------ site/smart-accounts/custom/using-your-own.md | 42 ++++++++++++ site/smart-accounts/gas-benchmarks.md | 25 +++++++ site/smart-accounts/index.md | 2 +- 9 files changed, 78 insertions(+), 117 deletions(-) delete mode 100644 site/smart-accounts/accounts/guides/using-your-own.md rename site/smart-accounts/{accounts => custom}/contributing.md (56%) create mode 100644 site/smart-accounts/custom/using-your-own.md create mode 100644 site/smart-accounts/gas-benchmarks.md diff --git a/site/.vitepress/sidebar/new.ts b/site/.vitepress/sidebar/new.ts index 5a38228fcd..bb2af82c03 100644 --- a/site/.vitepress/sidebar/new.ts +++ b/site/.vitepress/sidebar/new.ts @@ -53,12 +53,13 @@ export const newSidebar: DefaultTheme.Sidebar = [ { text: "Custom Accounts", collapsed: true, + base: "/smart-accounts/custom", items: [ - { text: "Use your own", link: "/" }, - { text: "Contribute your account", link: "/" }, + { text: "Use your own", link: "/using-your-own" }, + { text: "Contribute your account", link: "/contributing" }, ], }, - { text: "Gas Benchmarks", link: "/" }, + { text: "Gas Benchmarks", link: "/smart-accounts/gas-benchmarks" }, ], }, { diff --git a/site/getting-started/deploy-an-account.md b/site/getting-started/deploy-an-account.md index 08d8bde726..485857ac5c 100644 --- a/site/getting-started/deploy-an-account.md +++ b/site/getting-started/deploy-an-account.md @@ -32,7 +32,7 @@ The next step is to select the right smart account implementation for your appli - [Using Modular Accounts](/smart-accounts/modular-account/) - [Using Light Account](/smart-accounts/light-account/) -- [Using your own account implementation](/smart-accounts/accounts/guides/using-your-own) +- [Using your own account implementation](/smart-accounts/custom/using-your-own) ::: tip Note The `LightAccount` implementation is not [ERC-6900](/smart-accounts/modular-account/) compliant. The `ModularAccount` implementation is launching later this year and will be EIP-6900 compatible. However, `LightAccount` is forward-compatible with `ModularAccount` and can be upgraded to it in the future. diff --git a/site/overview/introduction.md b/site/overview/introduction.md index de15845156..7a1edf0408 100644 --- a/site/overview/introduction.md +++ b/site/overview/introduction.md @@ -42,7 +42,7 @@ The `aa-sdk` is a type-safe and performant TypeScript library built on top of [v The SDK also implements an EIP-1193 provider interface to easily plug into any popular dapp or wallet connect libraries such as RainbowKit, Wagmi, and Web3Modal. It also includes ethers.js adapters to provide full support for ethers.js apps. -The `aa-sdk` is modular at every layer of the stack and can be easily extended to fit your custom needs. You can plug in any [smart account](/smart-accounts/accounts/guides/using-your-own) implementation, [Signer](/smart-accounts/signers/choosing-a-signer), Gas Manager API, RPC provider. +The `aa-sdk` is modular at every layer of the stack and can be easily extended to fit your custom needs. You can plug in any [smart account](/smart-accounts/custom/using-your-own) implementation, [Signer](/smart-accounts/signers/choosing-a-signer), Gas Manager API, RPC provider. Get started with `aa-sdk` in our [Getting Started guide](/getting-started/setup) or checkout the [open source repo](https://github.com/alchemyplatform/aa-sdk). diff --git a/site/overview/package-overview.md b/site/overview/package-overview.md index a4dc0278db..7adba9fae8 100644 --- a/site/overview/package-overview.md +++ b/site/overview/package-overview.md @@ -47,7 +47,7 @@ For more details on all the utilities exported by `aa-alchemy` see the [aa-alche ## [`aa-accounts`](/packages/aa-accounts/) -This packages provides various implementations of `BaseSmartContractAccount` for interacting with different smart accounts. This package is not required to use `aa-core` or `aa-alchemy`. If you want to use your own smart account implementation, you can do so by following the guide ["Using Your Own Account"](/smart-accounts/accounts/guides/using-your-own). +This packages provides various implementations of `BaseSmartContractAccount` for interacting with different smart accounts. This package is not required to use `aa-core` or `aa-alchemy`. If you want to use your own smart account implementation, you can do so by following the guide ["Using Your Own Account"](/smart-accounts/custom/using-your-own). If you'd like to use a smart account that is not supported by this package, you can implement `BaseSmartContractAccount` yourself and use it with `aa-core` or `aa-alchemy` @@ -57,7 +57,7 @@ To see all of the smart accounts that are supported by this package, see the [aa ## [`aa-signers`](/packages/aa-signers/) -This packages provides various implementations of `SmartAccountSigner` and `SmartAccountAuthenticator` for integrating different Signers of your smart account. This package is not required to use `aa-core` or `aa-alchemy`. If you want to use your own Smart Account implementation, you can do so by following the guide ["Using Your Own Account"](/smart-accounts/accounts/guides/using-your-own). +This packages provides various implementations of `SmartAccountSigner` and `SmartAccountAuthenticator` for integrating different Signers of your smart account. This package is not required to use `aa-core` or `aa-alchemy`. If you want to use your own Smart Account implementation, you can do so by following the guide ["Using Your Own Account"](/smart-accounts/custom/using-your-own). If you'd like to use a signer that is not supported by this package, you can implement a `SmartAccountSigner` or `SmartAccountAuthenticator` yourself and use it with `aa-core` or `aa-alchemy`. diff --git a/site/smart-accounts/accounts/guides/using-your-own.md b/site/smart-accounts/accounts/guides/using-your-own.md deleted file mode 100644 index 6296ba0cf1..0000000000 --- a/site/smart-accounts/accounts/guides/using-your-own.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -outline: deep -head: - - - meta - - property: og:title - content: Using Your Own Smart Account - - - meta - - name: description - content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - - meta - - property: og:description - content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - - meta - - name: twitter:title - content: Using Your Own Smart Account - - - meta - - name: twitter:description - content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. ---- - -# Using Your Own Smart Account - -You are not limited to the accounts defined in `@alchemy/aa-accounts`. The `SmartAccountProvider` can be used with any smart account because it only relies on the [`ISmartContractAccount`](https://github.com/alchemyplatform/aa-sdk/blob/main/packages/core/src/account/types.ts#L8) interface. This means you can use your own smart account implementation with Account Kit. - -## Implementing `ISmartContractAccount` - -Let's take a look at [`BaseSmartContractAccount`](https://github.com/alchemyplatform/aa-sdk/blob/main/packages/core/src/account/base.ts) and walk through an example of implementing an interface to work with your own Smart Contract Account. - -:::tip Note -If you want to add your smart account implementation to Account Kit's codebase, take a look at the [contibuting](/smart-accounts/accounts/contributing) docs. We welcome Pull Requests onto the Github repo for [`aa-sdk`](https://github.com/alchemyplatform/aa-sdk)! -::: - -### 1. Extend `BaseSmartContractAccount` - -In `aa-core`, we provide an abstract class that handles most of the `ISmartContractAccount` interface, making this very simple! - -The `BaseSmartContractAccount` class leaves four methods as abstract for you to implement in your own class: - -::: details Click to expand -<<< @/../packages/core/src/account/base.ts#abstract-methods -::: - -### 2. Implement Additional methods from `BaseSmartContractAccount` - -The `BaseSmartContractAccount` class also exposes some additional implementations that by default will throw an error if not implemented. You can override these methods to provide your own implementation: - -::: details Click to expand -<<< @/../packages/core/src/account/base.ts#optional-methods -::: - -## `LightSmartContractAccount` as an Example - -We have built an extension of the eth-infinitism `SimpleAccount` called [LightAccount.sol](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol). You can learn more about Light Account in the [Light Account documentation](/smart-accounts/light-account/). - -We provide an implementation of `ISmartContractAccount` that works with `LightAccount.sol` which can be used as an example of how to implement your own Smart Contract Account: -::: details LightSmartContractAccount -<<< @/../packages/accounts/src/light-account/account.ts -::: - -## The `ISmartContractAccount` Interface - -For your reference, this is the definition of the `ISmartContractAccount` interface as pulled from the source code: - -::: details ISmartContractAccount -<<< @/../packages/core/src/account/types.ts -::: diff --git a/site/smart-accounts/accounts/contributing.md b/site/smart-accounts/custom/contributing.md similarity index 56% rename from site/smart-accounts/accounts/contributing.md rename to site/smart-accounts/custom/contributing.md index bc13a46af2..89f1f1f621 100644 --- a/site/smart-accounts/accounts/contributing.md +++ b/site/smart-accounts/custom/contributing.md @@ -26,7 +26,7 @@ If you'd like to add your smart account to Account Kit, we welcome PRs! You'll n To ensure the best developer experience for anyone using Account Kit, we ask that you add your smart account implementation to our [`aa-accounts`](https://github.com/alchemyplatform/aa-sdk/tree/main/packages/accounts) SDK package. -There, you'll want to add an implemention of the [`ISmartContractAccount`](https://github.com/alchemyplatform/aa-sdk/blob/main/packages/core/src/account/types.ts#L23) interface from `aa-core`. Make sure to include unit tests along with your implementation! +There, you'll want to add an implemention of the [`SmartContractAccount`](https://github.com/alchemyplatform/aa-sdk/blob/main/packages/core/src/account/smartContractAccount.ts) interface from `aa-core`. Simply export a function `createMySmartContractAccount` which calls `toSmartContractAccount` and any custom setup you need for your account. Make sure to include unit tests along with your implementation! ## 2. Add Documentation about Your Smart Account @@ -34,10 +34,6 @@ You'll want to add documentation about your smart account so that developers can To ensure these docs are visible on the Account Kit docs, you'll want to add links to them in the [`site/.vitepress/config.ts`](https://github.com/alchemyplatform/aa-sdk/blob/main/site/.vitepress/config.ts) file in the `aa-sdk` repo, where there is a `sidebar` property in the object. -### 2.1 Adding API Documentation - -If your smart account implements the `SmartAccountAuthenticator` interface, you'll have at least 5 methods to document: `getAddress`, `authenticate`, `signMessage`, `signTypedData`, and `getAuthDetails`. You can also add additional methods to your implementation. Just make sure to add documentation! - Find the `aa-accounts` item in the `sidebar` and add a new entry in `items`. The `text` property of the entry is what will be visible in the sidebar and the `link` property should be `kebab-case`: ```ts @@ -66,44 +62,7 @@ Find the `aa-accounts` item in the `sidebar` and add a new entry in `items`. The } ``` -In that section, add documentation introducing the value prop of your smart account, how to initialize the smart account object, and how to call each method. The example above shows the items you'll need to include if you chose to have your smart account implement the `SmartAccountAuthenticator` interface. - -### 2.2 Adding an integration guide - -You'll want to add an integration guide that walks through step-by-step how to use your smart account implementation in `aa-accounts` with the other building blocks, namely provider clients. - -Find the `Choosing a Smart Account` item in the `sidebar` and add a new entry in `items`. The `text` property of the entry is what will be visible in the sidebar and the `link` property should be `kebab-case`: - -```ts -{ - sidebar: [ - // ... other entries - { - text: "Choosing a Smart Account", - base: "/smart-accounts/accounts", - items: [ - { text: "Introduction", link: "/choosing-a-smart-account" }, - { - text: "Smart Account Guides", - base: "/smart-accounts/accounts/guides", - collapsed: true, - items: [ - // ... other smart accounts - { text: "Your Account", link: "/your-account-name" }, - { text: "Light Account", link: "/light-account" }, - { text: "Modular Account", link: "/modular-account" }, - { text: "Using Your Own", link: "/using-your-own" }, - ], - }, - { text: "Deployments", link: "/deployment-addresses" }, - { text: "Contributing Your Account", link: "/contributing" }, - ], - }, - ]; -} -``` - -In that linked file `your-account-name` under Smart Account Guides, add your step-by-step integration. Try to include an example snippet when possible. +In that section, add documentation introducing the value prop of your smart account, how to initialize the smart account object, and how to call each method. ## 3. Submit a Pull Request diff --git a/site/smart-accounts/custom/using-your-own.md b/site/smart-accounts/custom/using-your-own.md new file mode 100644 index 0000000000..f9a32ed947 --- /dev/null +++ b/site/smart-accounts/custom/using-your-own.md @@ -0,0 +1,42 @@ +--- +outline: deep +head: + - - meta + - property: og:title + content: Using Your Own Smart Account + - - meta + - name: description + content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + - - meta + - property: og:description + content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + - - meta + - name: twitter:title + content: Using Your Own Smart Account + - - meta + - name: twitter:description + content: Follow this guide to use any smart account implementation you want with Account Kit, a vertically integrated stack for building apps that support ERC-4337. +--- + +# Using Your Own Smart Account + +You are not limited to the accounts defined in `@alchemy/aa-accounts`. The `SmartAccountProvider` can be used with any smart account because it only relies on the [`ISmartContractAccount`](https://github.com/alchemyplatform/aa-sdk/blob/main/packages/core/src/account/types.ts#L8) interface. This means you can use your own smart account implementation with Account Kit. + + + +## `LightSmartContractAccount` as an Example + +We have built an extension of the eth-infinitism `SimpleAccount` called [LightAccount.sol](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol). You can learn more about Light Account in the [Light Account documentation](/smart-accounts/light-account/). + +We provide an implementation of `SmartContractAccount` that works with `LightAccount.sol` which can be used as an example of how to implement your own Smart Contract Account: +::: details LightSmartContractAccount +<<< @/../packages/accounts/src/light-account/account.ts +::: + +## The `toSmartContractAccount` Method + +For your reference, this is the definition of the `toSmartContractAccount` interface as pulled from the source code: + +::: details SmartContractAccount +<<< @/../packages/core/src/account/smartContractAccount.ts +::: diff --git a/site/smart-accounts/gas-benchmarks.md b/site/smart-accounts/gas-benchmarks.md new file mode 100644 index 0000000000..e069856941 --- /dev/null +++ b/site/smart-accounts/gas-benchmarks.md @@ -0,0 +1,25 @@ +--- +outline: deep +head: + - - meta + - property: og:title + content: Gas Benchmarks + - - meta + - name: description + content: Gas Benchmarks for Alchemy Accounts + - - meta + - property: og:description + content: Gas Benchmarks for Alchemy Accounts +--- + +# Account Gas Benchmarks + +| Account | Native transfer | ERC20 transfer | Creation | +| ----------------------------------------------------------------------------------------------------------------------- | --------------- | -------------- | -------- | +| Alchemy Light Account | 100844 | 90345 | 279746 | +| Kernel v2.1-lite | 101002 | 90321 | 230968 | +| [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) | 101319 | 90907 | 383218 | +| Etherspot | 103719 | 93324 | 279219 | +| Biconomy | 104408 | 93730 | 270013 | +| Kernel v2.1 | 106460 | 96038 | 265215 | +| Kernel v2.0 | 110018 | 99622 | 339882 | diff --git a/site/smart-accounts/index.md b/site/smart-accounts/index.md index 5ae37ee0ab..50002a7d75 100644 --- a/site/smart-accounts/index.md +++ b/site/smart-accounts/index.md @@ -44,4 +44,4 @@ We are authoring a standard for modular smart accounts called [ERC-6900](https:/ ## Use Your Own Account -If Light Account doesn't fit your specific needs, you can always use your own smart account implementation with Account Kit. To learn how, see our guide in the [Using Your Own](/smart-accounts/accounts/guides/using-your-own) section. +If Light Account doesn't fit your specific needs, you can always use your own smart account implementation with Account Kit. To learn how, see our guide in the [Using Your Own](/smart-accounts/custom/using-your-own) section. From 6965d748ea7059aa323a1031537c8362c3b00f30 Mon Sep 17 00:00:00 2001 From: moldy Date: Thu, 1 Feb 2024 14:26:04 -0500 Subject: [PATCH 4/4] docs: refactor using smart accounts docs --- packages/core/src/index.ts | 1 - site/.vitepress/sidebar/new.ts | 45 +++++++++----- site/faqs.md | 6 +- site/getting-started/deploy-an-account.md | 6 +- site/getting-started/setup.md | 6 +- site/glossary/terms.md | 2 +- site/overview/introduction.md | 2 +- site/overview/why-account-kit.md | 8 +-- .../actions/checkGasSponsorshipEligibility.md | 2 +- .../types/userOperationOverrides.md | 2 +- .../light-account/deployments.md | 32 ---------- .../light-account/getting-started.md | 49 ---------------- site/smart-accounts/light-account/index.md | 40 +++++++------ .../signers/choosing-a-signer.md | 2 +- site/smart-accounts/signers/guides/dfns.md | 4 +- .../snippets/aa-alchemy/gas-manager-client.ts | 11 ++++ site/snippets/aa-core/smartAccountClient.ts | 2 +- site/snippets/enhanced-apis-example/nft.ts | 6 +- site/snippets/enhanced-apis-example/token.ts | 6 +- site/snippets/send-uo-example/full-example.ts | 4 +- .../batch-user-operations.md} | 58 ++++++++++--------- .../enhanced-apis/nft.md | 2 +- .../enhanced-apis/token.md | 2 +- .../send-user-operations.md} | 5 +- site/using-smart-accounts/session-keys.md | 0 .../simulate-user-operations.md} | 3 - .../sponsoring-gas/checking-eligibility.md} | 50 ++++++++-------- .../sponsoring-gas/gas-manager.md} | 55 ++---------------- .../transfer-ownership/light-account.md} | 26 +++++---- .../transfer-ownership/modular-account.md | 0 30 files changed, 172 insertions(+), 265 deletions(-) delete mode 100644 site/smart-accounts/light-account/deployments.md delete mode 100644 site/smart-accounts/light-account/getting-started.md create mode 100644 site/snippets/aa-alchemy/gas-manager-client.ts rename site/{tutorials/batching-transactions.md => using-smart-accounts/batch-user-operations.md} (68%) rename site/{tutorials => using-smart-accounts}/enhanced-apis/nft.md (97%) rename site/{tutorials => using-smart-accounts}/enhanced-apis/token.md (98%) rename site/{tutorials/send-user-operation.md => using-smart-accounts/send-user-operations.md} (97%) create mode 100644 site/using-smart-accounts/session-keys.md rename site/{tutorials/sim-user-operation.md => using-smart-accounts/simulate-user-operations.md} (98%) rename site/{tutorials/sponsoring-gas/gas-sponsorship-eligibility.md => using-smart-accounts/sponsoring-gas/checking-eligibility.md} (72%) rename site/{tutorials/sponsoring-gas/sponsoring-gas.md => using-smart-accounts/sponsoring-gas/gas-manager.md} (71%) rename site/{tutorials/transferring-ownership.md => using-smart-accounts/transfer-ownership/light-account.md} (75%) create mode 100644 site/using-smart-accounts/transfer-ownership/modular-account.md diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 94dc810b33..9d5f22d176 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -57,7 +57,6 @@ export { isSmartAccountClient } from "./client/isSmartAccountClient.js"; export { ConnectionConfigSchema, SmartAccountClientOptsSchema as SmartAccountProviderOptsSchema, - createPublicErc4337ClientSchema, } from "./client/schema.js"; export type * from "./client/smartAccountClient.js"; export { diff --git a/site/.vitepress/sidebar/new.ts b/site/.vitepress/sidebar/new.ts index bb2af82c03..ec9be91b7c 100644 --- a/site/.vitepress/sidebar/new.ts +++ b/site/.vitepress/sidebar/new.ts @@ -42,13 +42,7 @@ export const newSidebar: DefaultTheme.Sidebar = [ }, { text: "Light Account", - collapsed: true, - base: "/smart-accounts/light-account", - items: [ - { text: "Introduction", link: "/" }, - { text: "Getting started", link: "/getting-started" }, - { text: "Deployments", link: "/deployments" }, - ], + link: "/smart-accounts/light-account/", }, { text: "Custom Accounts", @@ -105,17 +99,42 @@ export const newSidebar: DefaultTheme.Sidebar = [ }, { text: "Using Smart Accounts", + base: "/using-smart-accounts", items: [ - { text: "Send User Operations", link: "/" }, - { text: "Batch User Operations", link: "/" }, - { text: "Simulate User Operations", link: "/" }, + { text: "Send User Operations", link: "/send-user-operations" }, + { text: "Batch User Operations", link: "/batch-user-operations" }, + { + text: "Sponsoring Gas", + collapsed: false, + base: "/using-smart-accounts/sponsoring-gas", + items: [ + { text: "Alchemy Gas Manager", link: "/gas-manager" }, + { text: "Check Eligibility", link: "/checking-eligibility" }, + ], + }, + { text: "Simulate User Operations", link: "/simulate-user-operations" }, { text: "Transfer Ownership", + base: "/using-smart-accounts/transfer-ownership", collapsed: false, - items: [{ text: "Modular Account" }, { text: "Light Account" }], + items: [ + { text: "Modular Account", link: "/modular-account" }, + { text: "Light Account", link: "/light-account" }, + ], + }, + { text: "Session Keys", link: "/session-keys" }, + { + text: "Alchemy Enhanced Apis", + base: "/using-smart-accounts/enhanced-apis", + collapsed: true, + items: [ + { + text: "Get Account's NFTs", + link: "/nft", + }, + { text: "Get Account's Tokens", link: "/token" }, + ], }, - { text: "Session Keys", link: "/" }, - { text: "Alchemy Enhanced Apis", link: "/" }, ], }, { diff --git a/site/faqs.md b/site/faqs.md index 53bb0c06c0..ed3bcd9d77 100644 --- a/site/faqs.md +++ b/site/faqs.md @@ -78,7 +78,7 @@ Right now, `UserOperation`s are sent to a private mempool for all networks other ### Can I simulate `UserOperation`s the same way I simulate transactions? ::: details Answer -Yes! Check out [this guide](/tutorials/sim-user-operation.html). +Yes! Check out [this guide](/using-smart-accounts/simulate-user-operations.html). ::: ## Gas Estimation @@ -106,7 +106,7 @@ Gas sponsorship is available on testnet for all tiers. For support on mainnet, y ### How is gas sponsored? Do I need to fund the Gas Manager? ::: details Answer -We front the gas for your application and put the USD equivalent on your bill at the end of the month. No need to worry about pre-funding the Gas Manager or conversions, we’ve got you covered! You can follow [this guide](/tutorials/sponsoring-gas/sponsoring-gas.html) for more details on how to sponsor `UserOperation`s. +We front the gas for your application and put the USD equivalent on your bill at the end of the month. No need to worry about pre-funding the Gas Manager or conversions, we’ve got you covered! You can follow [this guide](/using-smart-accounts/sponsoring-gas/gas-manager.html) for more details on how to sponsor `UserOperation`s. ::: ### What are my gas sponsorship limits? @@ -124,7 +124,7 @@ Currently, we don’t support this, but we are actively exploring. Please [reach ### How is the Gas Manager protected from DDOS attacks? ::: details Answer -In your Gas Manager policy, you can configure spending rules per address, per app, and/or policy wide limits. See how to set up these policies [here](/tutorials/sponsoring-gas/sponsoring-gas.html#_2-create-a-gas-manager-policy). +In your Gas Manager policy, you can configure spending rules per address, per app, and/or policy wide limits. See how to set up these policies [here](/using-smart-accounts/sponsoring-gas/gas-manager.html#_2-create-a-gas-manager-policy). ::: ## Common Errors {#common-errors} diff --git a/site/getting-started/deploy-an-account.md b/site/getting-started/deploy-an-account.md index 485857ac5c..72daca3ece 100644 --- a/site/getting-started/deploy-an-account.md +++ b/site/getting-started/deploy-an-account.md @@ -46,12 +46,12 @@ At this point you should be able to integrate smart accounts in your application ## 4. Sponsoring Gas -Being able to sponsor gas for your users is one of the most powerful features enabled by smart accounts and can help you build a seamless user experience. We'll cover this in detail with code examples in the [Sponsoring Gas](/tutorials/sponsoring-gas/sponsoring-gas) section. +Being able to sponsor gas for your users is one of the most powerful features enabled by smart accounts and can help you build a seamless user experience. We'll cover this in detail with code examples in the [Sponsoring Gas](/using-smart-accounts/sponsoring-gas/gas-manager) section. ## 5. Batching Transactions -Transaction batching allows you to bundle multiple transaction calls into a single User Operation and execute them in a single atomic transaction. This can help you save on gas costs and improve the user experience. We'll cover this in detail with code examples in the [Batching Transactions](/tutorials/batching-transactions) section. +Transaction batching allows you to bundle multiple transaction calls into a single User Operation and execute them in a single atomic transaction. This can help you save on gas costs and improve the user experience. We'll cover this in detail with code examples in the [Batching Transactions](/using-smart-accounts/batch-user-operations) section. ## 6. Transferring Ownership -Ownership is an important aspect of smart accounts. The Light Account implementation allows you to transfer the ownership of a smart account to another entity. We'll cover this in detail with code examples in the [Transferring Ownership](/tutorials/transferring-ownership) section. +Ownership is an important aspect of smart accounts. The Light Account implementation allows you to transfer the ownership of a smart account to another entity. We'll cover this in detail with code examples in the [Transferring Ownership](/using-smart-accounts/transfer-ownership/light-account) section. diff --git a/site/getting-started/setup.md b/site/getting-started/setup.md index f675d98057..1f3aaf1ac4 100644 --- a/site/getting-started/setup.md +++ b/site/getting-started/setup.md @@ -115,7 +115,7 @@ Smart Account Address: 0xYOUR_SMART_ACCOUNT_ADDRESS To deploy the smart account and send UOs on its behalf, you'll need to add native token to your smart account. -At scale, you might consider using our Gas Manager to [sponsor UserOperations](/tutorials/sponsoring-gas/sponsoring-gas) for smart accounts. But for the purpose of this example, and because we're using a testnet, let's fund the account using the [Alchemy Faucet](https://sepoliafaucet.com). Make sure to log in with Alchemy to receive your testnet tokens. +At scale, you might consider using our Gas Manager to [sponsor UserOperations](/using-smart-accounts/sponsoring-gas/gas-manager) for smart accounts. But for the purpose of this example, and because we're using a testnet, let's fund the account using the [Alchemy Faucet](https://sepoliafaucet.com). Make sure to log in with Alchemy to receive your testnet tokens. Account Kit Overview @@ -167,8 +167,8 @@ In this guide, we initialized an `AlchemyProvider` with the `aa-alchemy` package 3. To learn about the `owner` field on your smart account, check out the section on [Choosing a Signer](/smart-accounts/signers/choosing-a-signer) to own the smart account. -4. To learn more about different User Operations you can send with different `target` and `data` fields in the `sendUserOperation` function above, look at our [How to Send a User Operation](/tutorials/send-user-operation) guide for an example using NFT mints. +4. To learn more about different User Operations you can send with different `target` and `data` fields in the `sendUserOperation` function above, look at our [How to Send a User Operation](/using-smart-accounts/send-user-operations) guide for an example using NFT mints. -5. To explore more ways to use Account Kit, check out the many step-by-step guides, such as [How to Sponsor Gas for a User Operation](/tutorials/sponsoring-gas/sponsoring-gas) or [How to Fetch Smart Account Data](/tutorials/enhanced-apis/nft). +5. To explore more ways to use Account Kit, check out the many step-by-step guides, such as [How to Sponsor Gas for a User Operation](/using-smart-accounts/sponsoring-gas/gas-manager) or [How to Fetch Smart Account Data](/using-smart-accounts/enhanced-apis/nft). 6. To see Account Kit in action, check out our [Demos](/overview/demos). diff --git a/site/glossary/terms.md b/site/glossary/terms.md index 9935ed7cb0..4e240c671d 100644 --- a/site/glossary/terms.md +++ b/site/glossary/terms.md @@ -22,7 +22,7 @@ head: ## Account Kit -Account Kit is a framework designed to embed smart accounts in web3 applications. It includes a set of tools such as [Signer integrations](https://accountkit.alchemy.com/smart-accounts/signers/choosing-a-signer.html), [Gas Manager](https://docs.alchemy.com/docs/gas-manager-services) and [Bundler](https://docs.alchemy.com/docs/bundler-services) utilities that unlock features such as [gas sponsorship](https://accountkit.alchemy.com/tutorials/sponsoring-gas/sponsoring-gas.html), [batched transactions](https://accountkit.alchemy.com/tutorials/batching-transactions.html) and email/social login. With its user-friendly suite of SDKs, known as [aa-sdk](https://github.com/alchemyplatform/aa-sdk), Account Kit makes it easy to deploy smart accounts, manage `UserOperation`s, and handle gas sponsorship, streamlining the entire process with minimal coding effort. +Account Kit is a framework designed to embed smart accounts in web3 applications. It includes a set of tools such as [Signer integrations](https://accountkit.alchemy.com/smart-accounts/signers/choosing-a-signer.html), [Gas Manager](https://docs.alchemy.com/docs/gas-manager-services) and [Bundler](https://docs.alchemy.com/docs/bundler-services) utilities that unlock features such as [gas sponsorship](https://accountkit.alchemy.com/using-smart-accounts/sponsoring-gas/gas-manager.html), [batched transactions](https://accountkit.alchemy.com/using-smart-accounts/batch-user-operations.html) and email/social login. With its user-friendly suite of SDKs, known as [aa-sdk](https://github.com/alchemyplatform/aa-sdk), Account Kit makes it easy to deploy smart accounts, manage `UserOperation`s, and handle gas sponsorship, streamlining the entire process with minimal coding effort. ## Bundler diff --git a/site/overview/introduction.md b/site/overview/introduction.md index 7a1edf0408..f43fc65bf5 100644 --- a/site/overview/introduction.md +++ b/site/overview/introduction.md @@ -72,7 +72,7 @@ To get started with a Signer, read the doc: [How to Choose a Signer](/smart-acco The Gas Manager is a programmable API to sponsor gas for UserOps. You can create programmable gas policies to specify exactly which transactions should be sponsored, set strict spending limits per wallet or globally, and allowlist/blocklist particular wallet addresses. This expressive programmability is available through a REST API and an intuitive dashboard interface. -To learn how to sponsor gas with the Gas Manager API, see the [Sponsoring Gas](/tutorials/sponsoring-gas/sponsoring-gas) tutorial. +To learn how to sponsor gas with the Gas Manager API, see the [Sponsoring Gas](/using-smart-accounts/sponsoring-gas/gas-manager) tutorial. ### Bundler API diff --git a/site/overview/why-account-kit.md b/site/overview/why-account-kit.md index cdd982f88c..3a90ff5f40 100644 --- a/site/overview/why-account-kit.md +++ b/site/overview/why-account-kit.md @@ -65,7 +65,7 @@ Streamline your sign up flow with simple web2 login options supported by Account - Self-custodial wallets like MetaMask or Ledger - and more -Account Kit integrates all the leading wallet Signers with integration guides that you can find [here](/smart-accounts/signers/choosing-a-signer). Account Kit even supports self-custodial wallets like MetaMask or Ledger. Users can even change their Signer later via Account Kit’s [ownership transfer](/tutorials/transferring-ownership) functionality. +Account Kit integrates all the leading wallet Signers with integration guides that you can find [here](/smart-accounts/signers/choosing-a-signer). Account Kit even supports self-custodial wallets like MetaMask or Ledger. Users can even change their Signer later via Account Kit’s [ownership transfer](/using-smart-accounts/transfer-ownership/light-account) functionality. Learn [how to choose and integrate the right Signer for your use case in this doc](/smart-accounts/signers/choosing-a-signer). @@ -75,15 +75,15 @@ Account Kit removes the greatest barrier to entry of all: gas fees. Many newcomers give up on web3 before submitting their first transaction. It's daunting to buy crypto for the first time, especially before trying the app! Gas fees -- even cheap ones on L2 -- discourage newcomers from trying your app. -With Account Kit you can remove this barrier by [sponsoring gas fees](/tutorials/sponsoring-gas/sponsoring-gas) for transactions — especially the first one! Get the user to your app’s magic moment as quickly, and help them fall in love with your product before asking them to deposit money. +With Account Kit you can remove this barrier by [sponsoring gas fees](/using-smart-accounts/sponsoring-gas/gas-manager) for transactions — especially the first one! Get the user to your app’s magic moment as quickly, and help them fall in love with your product before asking them to deposit money. -The [Gas Manager API](https://dashboard.alchemy.com/gas-manager/?a=ak-docs) included in Account Kit is a powerful tool to [sponsor gas](/tutorials/sponsoring-gas/sponsoring-gas). Sponsorship rules are programmable, giving you precise control over spending limits, allowlisted/blocklisted wallet addresses, and more through a REST API or an intuitive management dashboard. +The [Gas Manager API](https://dashboard.alchemy.com/gas-manager/?a=ak-docs) included in Account Kit is a powerful tool to [sponsor gas](/using-smart-accounts/sponsoring-gas/gas-manager). Sponsorship rules are programmable, giving you precise control over spending limits, allowlisted/blocklisted wallet addresses, and more through a REST API or an intuitive management dashboard. In the future, Account Kit will support paying gas in stablecoins like USDC and other ERC20s. If you’re interested those features, [contact us](mailto:account-abstraction@alchemy.com) to chat. ## Batch transactions -Streamline multi-step actions into a single click. Using the Bundler API, you can effortlessly [batch multiple transactions](/tutorials/batching-transactions) into a single operation. For example, imagine a normal user who wants to mint two NFTs as part of your giveaway. You can submit a single user operation that batches the following transactions together all with a single click and sponsored gas: +Streamline multi-step actions into a single click. Using the Bundler API, you can effortlessly [batch multiple transactions](/using-smart-accounts/batch-user-operations) into a single operation. For example, imagine a normal user who wants to mint two NFTs as part of your giveaway. You can submit a single user operation that batches the following transactions together all with a single click and sponsored gas: 1. Deploy a smart account contract for the user 2. Mint NFT #1 diff --git a/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md b/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md index b11a38b2d2..aaadeb4273 100644 --- a/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md +++ b/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md @@ -20,7 +20,7 @@ Internally, this method invokes [`buildUserOperation`](./buildUserOperation.md), You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility. -For a deeper understanding of how to employ this method to provide varied user experiences contingent on gas sponsorship eligibility, please refer to the guide [How to Handle User Operations Not Eligibile for Gas Sponsorship](/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md). +For a deeper understanding of how to employ this method to provide varied user experiences contingent on gas sponsorship eligibility, please refer to the guide [How to Handle User Operations Not Eligibile for Gas Sponsorship](/using-smart-accounts/sponsoring-gas/checking-eligibility.md). ## Usage diff --git a/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md b/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md index 1678a7ce7e..e855a32185 100644 --- a/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md +++ b/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md @@ -22,7 +22,7 @@ These override values are available from each middleware of the `SmartAccountPro Other than the `paymasterAndData` field, the override fields could be either the absolute value or the percentage value. In the default middlewares, if the override value is an absolute value, it simply overrides the estimated value. If the override value is a percentage value, the estimated value is _bumped_ with the indicated percentage value. For example, if the override value is `{ percentage: 10 }` for the `maxPriorityFeePerGas` field, then 10% bump is applied to the estimated `maxPriorityFeePerGas` of the user operation. -The `paymasterAndData` only allows an absolute value override, and if the override value is provided, then the paymaster middleware is bypassed entirely. Refer to our guide [How to Handle User Operations that are Not Eligible for Gas Sponsorship](/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md) on the example of using the `paymasterAndData` override to bypass the paymaster middleware to fallback to the user paying the gas fee instead of the gas being subsidized by the paymaster. +The `paymasterAndData` only allows an absolute value override, and if the override value is provided, then the paymaster middleware is bypassed entirely. Refer to our guide [How to Handle User Operations that are Not Eligible for Gas Sponsorship](/using-smart-accounts/sponsoring-gas/checking-eligibility.md) on the example of using the `paymasterAndData` override to bypass the paymaster middleware to fallback to the user paying the gas fee instead of the gas being subsidized by the paymaster. :::tip Note Note that if you are using your own middleware, for example a custom `feeEstimator` using config method on the client, then the default `feeEstimator` middleware is overriden. As you are opting out of using the default middleware, you are also responsible for handling the `UserOperationOverrides` appropriately. diff --git a/site/smart-accounts/light-account/deployments.md b/site/smart-accounts/light-account/deployments.md deleted file mode 100644 index 49d1bfc50c..0000000000 --- a/site/smart-accounts/light-account/deployments.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -outline: deep -head: - - - meta - - property: og:title - content: Light Account • Deployment Addresses - - - meta - - name: description - content: Deployment Addresses for Light Account - - - meta - - property: og:description - content: Deployment Addresses for Light Account ---- - -# [Deployment Addresses](https://github.com/alchemyplatform/light-account/blob/v1.1.0/Deployments.md) - -The following tables list the deployed factory and account implementation contract addresses for `LightAccount` on different chains: - -| Chain | Factory Address | Account Implementation | -| ---------------- | ------------------------------------------ | ------------------------------------------ | -| Eth Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Eth Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Eth Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Polygon Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Polygon Mumbai | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Optimism | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Optimism Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Base | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Base Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Arbitrum | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Arbitrum Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | -| Arbitrum Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | diff --git a/site/smart-accounts/light-account/getting-started.md b/site/smart-accounts/light-account/getting-started.md deleted file mode 100644 index 81d46ad2c1..0000000000 --- a/site/smart-accounts/light-account/getting-started.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -outline: deep -head: - - - meta - - property: og:title - content: Light Account • Getting Started - - - meta - - name: description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - - meta - - property: og:description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - - meta - - name: twitter:title - content: Light Account - - - meta - - name: twitter:description - content: Follow this guide to use Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. ---- - -# Getting started - -Getting started with Light Account is really simple! Simply create a `SmartAccountClient` and an instance of `LightAccount` and you're ready to go. - -## Import - -::: code-group - -```ts [aa-alchemy] -import { createLightAccountAlchemyClient } from "@alchemy/aa-alchemy"; -``` - -```ts [aa-core] -import { createLightAccount } from "@alchemy/aa-accounts"; -import { createSmartAccountClient } from "@alchemy/aa-core"; -``` - -::: - -## Usage - -The code snippet below demonstrates how to use Light Account with Account Kit. It creates a Light Account and sends a `UserOperation` from it: -::: code-group - -<<< @/snippets/aa-alchemy/light-account.ts [aa-alchemy] - -<<< @/snippets/aa-core/smartAccountClient.ts [aa-core] - -::: code-group diff --git a/site/smart-accounts/light-account/index.md b/site/smart-accounts/light-account/index.md index 11ed3d9f6a..8af11db778 100644 --- a/site/smart-accounts/light-account/index.md +++ b/site/smart-accounts/light-account/index.md @@ -24,31 +24,35 @@ head: Light Account is an [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart account. We started with the Ethereum Foundation’s canonical [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) and added key improvements. It's fully production-ready with a security [audit](https://github.com/alchemyplatform/light-account/blob/main/Quantstamp-Audit.pdf), gas optimizations, and [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271) signature support. Additionally, Light Account supports ownership transfer to ensure you and your user don't get locked into a particular Signer. -## Why Light Account +## Getting Started -### Gas-optimized +The code snippet below demonstrates how to use Light Account with Account Kit. It creates a Light Account and sends a `UserOperation` from it: +::: code-group -Light Account is engineered to minimize gas costs, as measured by the following benchmarks for common operations like native token transfers, ERC20 transfers, and account creation. +<<< @/snippets/aa-alchemy/light-account.ts [aa-alchemy] -#### Benchmarks +<<< @/snippets/aa-core/smartAccountClient.ts [aa-core] -| Account | Native transfer | ERC20 transfer | Creation | -| ----------------------------------------------------------------------------------------------------------------------- | --------------- | -------------- | -------- | -| Alchemy Light Account | 100844 | 90345 | 279746 | -| Kernel v2.1-lite | 101002 | 90321 | 230968 | -| [SimpleAccount](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) | 101319 | 90907 | 383218 | -| Etherspot | 103719 | 93324 | 279219 | -| Biconomy | 104408 | 93730 | 270013 | -| Kernel v2.1 | 106460 | 96038 | 265215 | -| Kernel v2.0 | 110018 | 99622 | 339882 | +::: code-group -### Secure, Audited, Open Source +## [Deployment Addresses](https://github.com/alchemyplatform/light-account/blob/v1.1.0/Deployments.md) -Light Account has been audited by Quantstamp. You can find the audit report [here](https://github.com/alchemyplatform/light-account/blob/main/Quantstamp-Audit.pdf). Light Account is is also fully open source so you can validate the [source code](https://github.com/alchemyplatform/light-account). +The following tables list the deployed factory and account implementation contract addresses for `LightAccount` on different chains: -### Modular 6900 Accounts (Coming Soon) - -We're pioneering the future of modular smart accounts with [EIP-6900](https://www.alchemy.com/blog/account-abstraction-erc-6900/?a=ak-docs). We're developing a [Modular Account](../modular-account/) to support EIP-6900 coming soon. Light Account is designed with that future in mind. It is forward-compatible with EIP-6900 so you can upgrade it to 6900-compatible account once the Modular Account is ready. +| Chain | Factory Address | Account Implementation | +| ---------------- | ------------------------------------------ | ------------------------------------------ | +| Eth Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Eth Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Eth Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Polygon Mainnet | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Polygon Mumbai | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Optimism | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Optimism Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Base | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Base Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum Goerli | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | +| Arbitrum Sepolia | 0x00004EC70002a32400f8ae005A26081065620D20 | 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba | ## Developer Links diff --git a/site/smart-accounts/signers/choosing-a-signer.md b/site/smart-accounts/signers/choosing-a-signer.md index fb9d63f7ce..580e20d43f 100644 --- a/site/smart-accounts/signers/choosing-a-signer.md +++ b/site/smart-accounts/signers/choosing-a-signer.md @@ -21,7 +21,7 @@ prev: link: /smart-accounts/ next: text: How to Send a User Operation - link: /tutorials/send-user-operation + link: /using-smart-accounts/send-user-operations --- # What is a Signer? diff --git a/site/smart-accounts/signers/guides/dfns.md b/site/smart-accounts/signers/guides/dfns.md index 46f412e96f..e08fc157ea 100644 --- a/site/smart-accounts/signers/guides/dfns.md +++ b/site/smart-accounts/signers/guides/dfns.md @@ -16,9 +16,9 @@ head: [Dfns](https://www.dfns.co) is an MPC/TSS Wallet-as-a-Service API/SDK provider. Dfns aims to optimize the balance of security and UX by deploying key shares into a decentralized network on the backend while enabling wallet access via biometric open standards on the frontend like Webauthn. Reach out [here](https://www.dfns.co/learn-more) to set up a sandbox environment to get started. -Dfns seamlessly integrates with Account Abstraction by signing `UserOperation`s. See the examples below for initializing a DFNS signer and creating a provider with that signer. You can follow [this](/tutorials/sponsoring-gas/sponsoring-gas.html) guide to send and sponsor `UserOperation`s with the provider created. +Dfns seamlessly integrates with Account Abstraction by signing `UserOperation`s. See the examples below for initializing a DFNS signer and creating a provider with that signer. You can follow [this](/using-smart-accounts/sponsoring-gas/gas-manager.html) guide to send and sponsor `UserOperation`s with the provider created. -Dfns created a full example of a gas-less transaction via a paymaster [in our SDK](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/viem/alchemy-aa-gasless), adapted from our [gas sponsorship example](/tutorials/sponsoring-gas/sponsoring-gas.html). +Dfns created a full example of a gas-less transaction via a paymaster [in our SDK](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/viem/alchemy-aa-gasless), adapted from our [gas sponsorship example](/using-smart-accounts/sponsoring-gas/gas-manager.html). ## Install Dfns SDK diff --git a/site/snippets/aa-alchemy/gas-manager-client.ts b/site/snippets/aa-alchemy/gas-manager-client.ts new file mode 100644 index 0000000000..bac58e0811 --- /dev/null +++ b/site/snippets/aa-alchemy/gas-manager-client.ts @@ -0,0 +1,11 @@ +import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy"; +import { LocalAccountSigner, sepolia } from "@alchemy/aa-core"; + +export const smartAccountClient = await createModularAccountAlchemyClient({ + apiKey: "ALCHEMY_API_KEY", + chain: sepolia, + owner: LocalAccountSigner.mnemonicToAccountSigner("OWNER_MNEMONIC"), // or any SmartAccountSigner + gasManagerConfig: { + policyId: "YourGasManagerPolicyId", + }, +}); diff --git a/site/snippets/aa-core/smartAccountClient.ts b/site/snippets/aa-core/smartAccountClient.ts index 359cbf9225..7178cc49fc 100644 --- a/site/snippets/aa-core/smartAccountClient.ts +++ b/site/snippets/aa-core/smartAccountClient.ts @@ -13,7 +13,7 @@ const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner( ); const rpcTransport = http("https://polygon-mumbai.g.alchemy.com/v2/demo"); -export const provider = createSmartAccountClient({ +export const smartAccountClient = createSmartAccountClient({ transport: rpcTransport, chain, account: await createLightAccount({ diff --git a/site/snippets/enhanced-apis-example/nft.ts b/site/snippets/enhanced-apis-example/nft.ts index 30cf059b5d..2f36042d3a 100644 --- a/site/snippets/enhanced-apis-example/nft.ts +++ b/site/snippets/enhanced-apis-example/nft.ts @@ -10,7 +10,7 @@ const alchemy = new Alchemy({ apiKey: "YOUR_API_KEY", }); -const provider = ( +const client = ( await createModularAccountAlchemyClient({ chain: sepolia, apiKey: "YOUR_API_KEY", @@ -18,7 +18,7 @@ const provider = ( }) ).extend(alchemyEnhancedApiActions(alchemy)); -const address = provider.getAddress(); +const address = client.getAddress(); // get all NFTs owned by the smart account -export const nfts = provider.nft.getNftsForOwner(address); +export const nfts = client.nft.getNftsForOwner(address); diff --git a/site/snippets/enhanced-apis-example/token.ts b/site/snippets/enhanced-apis-example/token.ts index 6c2da2136e..45a428ba9c 100644 --- a/site/snippets/enhanced-apis-example/token.ts +++ b/site/snippets/enhanced-apis-example/token.ts @@ -10,7 +10,7 @@ const alchemy = new Alchemy({ apiKey: "YOUR_API_KEY", }); -const provider = ( +const client = ( await createModularAccountAlchemyClient({ chain: sepolia, apiKey: "YOUR_API_KEY", @@ -18,7 +18,7 @@ const provider = ( }) ).extend(alchemyEnhancedApiActions(alchemy)); -const address = provider.getAddress(); +const address = client.getAddress(); // get all tokens owned by the smart account -export const tokenBalances = provider.core.getTokenBalances(address); +export const tokenBalances = client.core.getTokenBalances(address); diff --git a/site/snippets/send-uo-example/full-example.ts b/site/snippets/send-uo-example/full-example.ts index ebb0c6dce0..f1252a4352 100644 --- a/site/snippets/send-uo-example/full-example.ts +++ b/site/snippets/send-uo-example/full-example.ts @@ -1,4 +1,4 @@ -import { createLightAccountAlchemyClient } from "@alchemy/aa-alchemy"; +import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy"; import { LocalAccountSigner, sepolia, @@ -10,7 +10,7 @@ const PRIVATE_KEY = "0xYourEOAPrivateKey"; const eoaSigner: SmartAccountSigner = LocalAccountSigner.privateKeyToAccountSigner(`0x${PRIVATE_KEY}`); -const client = await createLightAccountAlchemyClient({ +const client = await createModularAccountAlchemyClient({ apiKey: "ALCHEMY_API_KEY", // replace with your Alchemy API Key chain: sepolia, owner: eoaSigner, diff --git a/site/tutorials/batching-transactions.md b/site/using-smart-accounts/batch-user-operations.md similarity index 68% rename from site/tutorials/batching-transactions.md rename to site/using-smart-accounts/batch-user-operations.md index 514d66f2ed..c5b1b52bd7 100644 --- a/site/tutorials/batching-transactions.md +++ b/site/using-smart-accounts/batch-user-operations.md @@ -27,8 +27,8 @@ There are two ways you can batch transactions using `SmartAccountProvider`: 1. via `sendUserOperation` 2. via `sendTransactions` -:::tip Note 1: `SimpleSmartContractAccount` and `LightSmartContractAccount` -Both `SimpleSmartContractAccount` and `LightSmartContractAccount` implement `encodeBatchExecute`, thus supports batching `UserOperations` out of the box. +:::tip Note 1: `LightSmartContractAccount`, and `MultiOwnerModularAccount` +Both `LightSmartContractAccount` and `MultiOwnerModularAccount` implement `encodeBatchExecute`, thus supports batching `UserOperations` out of the box. ::: :::tip Note 2: Transactions Batched as a Single User Operation @@ -36,7 +36,7 @@ When you batch transactions, the transaction actions (`target`s and `calldata`s) ::: :::tip Note 3: Batched Transactions Ordering -The batched UO gets executed by the account calling the `executeBatch` method on the [`SimpleAccount`](https://github.com/eth-infinitism/account-abstraction/blob/ver0.6.0/contracts/samples/SimpleAccount.sol) or [`LightAccount`](https://github.com/alchemyplatform/light-account/blob/v1.0.2/src/LightAccount.sol) smart contracts. `executeBatch` processes the input array of transactions data linearly, guaranteeing the execution order of those transactions to be **sequential**. +The batched UO gets executed by the account calling the `executeBatch` method on [`LightAccount`](https://github.com/alchemyplatform/light-account/blob/v1.0.2/src/LightAccount.sol) smart contracts. `executeBatch` processes the input array of transactions data linearly, guaranteeing the execution order of those transactions to be **sequential**. ::: ## Batching using [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) @@ -46,22 +46,24 @@ The `SmartAccountProvider` supports passing either a single UO or an array of UO ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // the hash returned here is the hash of the User Operation -const { hash } = await provider.sendUserOperation([ - { - target: "0x...", - data: "0xcallDataTransacation1", - }, - { - target: "0x...", - data: "0xcallDataTransacation2", - }, -]); +const { hash } = await smartAccountClient.sendUserOperation({ + uo: [ + { + target: "0x...", + data: "0xcallDataTransacation1", + }, + { + target: "0x...", + data: "0xcallDataTransacation2", + }, + ], +}); ``` -<<< @/snippets/aa-core/smartAccountClient.ts +<<< @/snippets/aa-alchemy/connected-client.ts [smartAccountClient.ts] ::: @@ -72,21 +74,23 @@ The `SmartAccountProvider` supports sending UOs and waiting for them to be mined ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // the hash returned here is the hash of the mined Tx that includes the UserOperation -const hash = await provider.sendTransactions([ - { - to: "0x...", - data: "0xcallDataTransacation1", - }, - { - to: "0x...", - data: "0xcallDataTransacation2", - }, -]); +const hash = await smartAccountClient.sendTransactions({ + requests: [ + { + to: "0x...", + data: "0xcallDataTransacation1", + }, + { + to: "0x...", + data: "0xcallDataTransacation2", + }, + ], +}); ``` -<<< @/snippets/aa-core/smartAccountClient.ts +<<< @/snippets/aa-alchemy/connected-client.ts [smartAccountClient.ts] ::: diff --git a/site/tutorials/enhanced-apis/nft.md b/site/using-smart-accounts/enhanced-apis/nft.md similarity index 97% rename from site/tutorials/enhanced-apis/nft.md rename to site/using-smart-accounts/enhanced-apis/nft.md index 0e046b7419..408d549df5 100644 --- a/site/tutorials/enhanced-apis/nft.md +++ b/site/using-smart-accounts/enhanced-apis/nft.md @@ -56,4 +56,4 @@ Note that we must configure the Alchemy SDK client to have the same API Key and Additionally, since the Alchemy SDK client does not yet support JWT authentication, an `AlchemySmartAccountClient` initialized with JWTs cannot use this method. We must be initialize the provider with an API key or RPC URL. ::: -That's it! There are so many more Enhanced APIs the the Alchemy SDK exposes, and can be useful for development with Account Abstraction. Try it out [here](https://github.com/alchemyplatform/alchemy-sdk-js), and check out [How to fetch a Smart Account's ERC-20 Tokens](/tutorials/enhanced-apis/token) for another example. +That's it! There are so many more Enhanced APIs the the Alchemy SDK exposes, and can be useful for development with Account Abstraction. Try it out [here](https://github.com/alchemyplatform/alchemy-sdk-js), and check out [How to fetch a Smart Account's ERC-20 Tokens](/using-smart-accounts/enhanced-apis/token) for another example. diff --git a/site/tutorials/enhanced-apis/token.md b/site/using-smart-accounts/enhanced-apis/token.md similarity index 98% rename from site/tutorials/enhanced-apis/token.md rename to site/using-smart-accounts/enhanced-apis/token.md index 7188827a1e..b72b074547 100644 --- a/site/tutorials/enhanced-apis/token.md +++ b/site/using-smart-accounts/enhanced-apis/token.md @@ -56,4 +56,4 @@ Note that we must configure the Alchemy SDK client to have the same API Key and Additionally, since the Alchemy SDK client does not yet support JWT authentication, an `AlchemySmartAccountClient` initialized with JWTs cannot use this method. We must be initialize the provider with an API key or RPC URL. ::: -That's it! There are so many more Enhanced APIs the the Alchemy SDK exposes, and can be useful for development with Account Abstraction. Try it out [here](https://github.com/alchemyplatform/alchemy-sdk-js), and check out [How to fetch a Smart Account's NFTs](/tutorials/enhanced-apis/nft) for another example. +That's it! There are so many more Enhanced APIs the the Alchemy SDK exposes, and can be useful for development with Account Abstraction. Try it out [here](https://github.com/alchemyplatform/alchemy-sdk-js), and check out [How to fetch a Smart Account's NFTs](/using-smart-accounts/enhanced-apis/nft) for another example. diff --git a/site/tutorials/send-user-operation.md b/site/using-smart-accounts/send-user-operations.md similarity index 97% rename from site/tutorials/send-user-operation.md rename to site/using-smart-accounts/send-user-operations.md index 67159c3f8f..510348f8dd 100644 --- a/site/tutorials/send-user-operation.md +++ b/site/using-smart-accounts/send-user-operations.md @@ -16,16 +16,13 @@ head: - - meta - name: twitter:description content: Follow this guide to send a User Operation with Account Kit, a vertically integrated stack for building apps that support ERC-4337. -prev: - text: Smart Accounts - link: /smart-accounts/overview --- # How to Send a User Operation This guide will show you how to send a User Operation with Account Kit by creating an Alchemy Smart Account Client, connecting it to a Light Account (a type of smart account implementation), and sending a User Operation from that provider. By the end of this guide, you'll have a basic understanding of how to use the SDK. -## 1. Create Your Provider +## 1. Create Your Client Using the SDK, we'll create an Alchemy Smart Account Client. As it is, the providers gives you methods to query information related to user operations and smart accounts. To create a provider, you'll need an Alchemy API Key or RPC URL, which you can access from the [Alchemy Dashboard](https://dashboard.alchemy.com/signup/?a=aa-docs). diff --git a/site/using-smart-accounts/session-keys.md b/site/using-smart-accounts/session-keys.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/site/tutorials/sim-user-operation.md b/site/using-smart-accounts/simulate-user-operations.md similarity index 98% rename from site/tutorials/sim-user-operation.md rename to site/using-smart-accounts/simulate-user-operations.md index 8df9841e53..82995837cd 100644 --- a/site/tutorials/sim-user-operation.md +++ b/site/using-smart-accounts/simulate-user-operations.md @@ -16,9 +16,6 @@ head: - - meta - name: twitter:description content: Follow this guide to simulate a User Operation with Alchemy's Account Kit, a vertically integrated stack for building apps that support ERC-4337. -prev: - text: Smart Accounts - link: /smart-accounts/overview --- # How to Simulate a User Operation diff --git a/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md b/site/using-smart-accounts/sponsoring-gas/checking-eligibility.md similarity index 72% rename from site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md rename to site/using-smart-accounts/sponsoring-gas/checking-eligibility.md index 1b2631352b..e185a76ecf 100644 --- a/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md +++ b/site/using-smart-accounts/sponsoring-gas/checking-eligibility.md @@ -20,35 +20,17 @@ head: # How to Handle User Operations that are Not Eligible for Gas Sponsorship -As mentioned from the previous guide on [How to Sponsor Gas for a User Operation](./sponsoring-gas.md), with Account Kit can sponsor gas fees for transactions via the [Gas Manager](https://docs.alchemy.com/docs/gas-manager-services/?a=ak-docs). +As mentioned from the previous guide on [How to Sponsor Gas for a User Operation](./gas-manager.md), with Account Kit can sponsor gas fees for transactions via the [Gas Manager](https://docs.alchemy.com/docs/gas-manager-services/?a=ak-docs). But what happens when the user operation you are sending fails to satisfy the criteria set in the gas manager policy? How do you check if the user operation is eligible for gas sponsorship before sending the user operation? -If you do send the user operation that is not eligible for the gas sponsorship under your Gas Manager policy, [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md) will fail due to the error thrown during the [`PaymasterMiddleware`](/packages/aa-core/smart-account-client/#common-to-both) failure. You can follow the guide below to check for gas sponsorship eligibility in advance. +If you do send the user operation that is not eligible for the gas sponsorship under your Gas Manager policy, [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md) will fail due to the error thrown during the `PaymasterMiddleware` failure. You can follow the guide below to check for gas sponsorship eligibility in advance. ## 1. How to Check if a User Operation is Eligible for Gas Sponsorship -First, you can follow the same instructions from the previous guide on [How to Sponsor Gas for a User Operation](./sponsoring-gas.md) to set up your `SmartAccountProvider` and link your gas policy. +First, you can follow the same instructions from the previous guide on [How to Sponsor Gas for a User Operation](./gas-manager.md) to set up your `AlchemySmartAccountClient` and link your gas policy. -::: code-group - -```ts [setup-alchemy-provider.ts] -import { provider } from "./provider.ts"; - -// Find your Gas Manager policy id at: // [!code focus:10] -//dashboard.alchemy.com/gas-manager/policy/create -const GAS_MANAGER_POLICY_ID = "YourGasManagerPolicyId"; - -// Link the provider with the Gas Manager. This ensures user operations -// sent with this provider get sponsorship from the Gas Manager. -provider.withAlchemyGasManager({ - policyId: GAS_MANAGER_POLICY_ID, -}); -``` - -<<< @/snippets/aa-core/smartAccountClient.ts - -::: +<<< @/snippets/aa-alchemy/gas-manager-client.ts Then, before you call `sendUserOperation` on the provider, you can use [`checkGasSponsorshipEligibility`](/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md) to verify the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent. @@ -56,8 +38,12 @@ Internally, this method invokes [`buildUserOperation`](/packages/aa-core/smart-a You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility. +::: code-group + ```ts [check-gas-sponsorship-eligibility.ts] -const elligibility = await provider.checkGasSponsorshipEligibility({ +import { smartAccountClient } from "./client"; + +const elligibility = await smartAccountClient.checkGasSponsorshipEligibility({ target: "0xTargetAddress", data: "0xCallData", value: 0n, // value in bigint or leave undefined @@ -70,21 +56,27 @@ console.log( ); ``` +<<< @/snippets/aa-alchemy/gas-manager-client.ts [client.ts] +::: + ## 2. How to Bypass the Paymaster Middleware For User Operations Not Eligible for Gas Sponsorship If you attempt to execute the `sendUserOperation` method for user operations ineligible for gas sponsorship through the configured provider with the gas manager policy, an error will be thrown. This error would prevent users from sending the user operation. In such cases, the desired user experience involves allowing these users, despite the lack of gas sponsorship eligibility, to still send the user operation by reverting to the default behavior of paying gas fees from the user's account balance. For instance, your application could inform users about their gas sponsorship eligibility status, surface the eligibility of the user operation, and provide users with the choice to unblock themselves by sending the user operation without gas sponsorship. This section of the guide elucidates how you can circumvent the `PaymasterMiddleware`, enabling the sending of user operations without gas sponsorship. This functionality permits the sending of user operations where users pay the gas fee themselves via their smart account. -When employing various methods on `SmartAccountProvider` to send user operations (e.g., [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md)), apart from the `UserOperationCallData` or `BatchUserOperationCallData`, you have the option to include an additional parameter named `overrides`. This parameter allows the specification of override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData`. To bypass the `PaymasterMiddleware`, you can specifically set the `paymasterAndData` override. For example, assigning an empty hex string (`0x`) to the `paymasterAndData` field in the overrides would result in the user operation being sent without the paymaster covering the gas fee, but rather paid from the user's own smart account. +When employing various methods on `SmartAccountClient` to send user operations (e.g., [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md)), apart from the `UserOperationCallData` or `BatchUserOperationCallData`, you have the option to include an additional parameter named `overrides`. This parameter allows the specification of override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData`. To bypass the `PaymasterMiddleware`, you can specifically set the `paymasterAndData` override. For example, assigning an empty hex string (`0x`) to the `paymasterAndData` field in the overrides would result in the user operation being sent without the paymaster covering the gas fee, but rather paid from the user's own smart account. + +::: code-group ```ts [bypass-paymaster-middleware.ts] +import { smartAccountClient } from "./client"; // If gas sponsorship ineligible, baypass paymaster middleware by passing in the paymasterAndData override // Empty paymasterAndData indicates that there will be no paymaster involved // and the user will be paying for the gas fee even when `withAlchemyGasManager` is configured on the provider -const elligibility = await provider.checkGasSponsorshipEligibility({ +const elligibility = await smartAccountClient.checkGasSponsorshipEligibility({ target: "0xTargetAddress", data: "0xCallData", value: 0n, // value in bigint or leave undefined @@ -96,7 +88,7 @@ const elligibility = await provider.checkGasSponsorshipEligibility({ // To proceed with bypassing the paymster middleware const overrides = { paymasterAndData: "0x" }; -const userOperationResult = await provider.sendUserOperation( +const userOperationResult = await smartAccountClient.sendUserOperation( { target: "0xTargetAddress", data: "0xCallData", @@ -104,11 +96,15 @@ const userOperationResult = await provider.sendUserOperation( overrides: elligibility ? undefined : overrides // for ineligible user operations, set the paymasterAndData override ); -const txHash = await provider.waitForUserOperationTransaction({ +const txHash = await smartAccountClient.waitForUserOperationTransaction({ hash: userOperationResult.hash, }); ``` +<<< @/snippets/aa-alchemy/gas-manager-client.ts [client.ts] + +::: + That's it! By using the above methods, you can provide the desired user experience for your users depending on their eligibility for gas sponsorship. 1. Check for the gas sponsorship eligibility prior to sending the user operation and inform users about their gas sponsorship eligibility status. diff --git a/site/tutorials/sponsoring-gas/sponsoring-gas.md b/site/using-smart-accounts/sponsoring-gas/gas-manager.md similarity index 71% rename from site/tutorials/sponsoring-gas/sponsoring-gas.md rename to site/using-smart-accounts/sponsoring-gas/gas-manager.md index e3b27a6d9f..96528d0645 100644 --- a/site/tutorials/sponsoring-gas/sponsoring-gas.md +++ b/site/using-smart-accounts/sponsoring-gas/gas-manager.md @@ -26,15 +26,7 @@ Gas fees are a significant barrier to entry for new user of your app. With Accou After [installing `aa-sdk`](/getting-started/setup#install-the-packages) in your project, follow these steps to sponsor gas. -### 1. Set Up the Provider - -First, create an `AlchemyProvider`. You'll use this to send UOs and interact with the blockchain. - -<<< @/snippets/aa-core/smartAccountClient.ts - -Remember to replace `ALCHEMY_API_KEY` with your Alchemy API key. If you don't have one yet, you can create an API key on the [Alchemy dashboard](https://dashboard.alchemy.com/signup/?a=aa-docs). - -### 2. Create a Gas Manager Policy +### 1. Create a Gas Manager Policy A gas manager policy is a set of rules that define which UOs are eligible for gas sponsorship. You can control which operations are eligible for sponsorship by defining rules: @@ -47,40 +39,15 @@ To learn more about policy configuration, refer to the guide on [setting up a ga Once you've decided on policy rules for your app, [create a policy](https://dashboard.alchemy.com/gas-manager/policy/create/?a=ak-docs) in the Gas Manager dashboard. -### 3. Link the Policy to your Provider +### 2. Create an `AlchemySmartAccountClient` that uses your policy -Next, you must link your gas policy to your provider. Find your Policy ID located at the top of the policy page in the Gas Manager dashboard. +Remember to replace `ALCHEMY_API_KEY` with your Alchemy API key. If you don't have one yet, you can create an API key on the [Alchemy dashboard](https://dashboard.alchemy.com/signup/?a=aa-docs). ![Policy ID](/images/policy-id.png) Copy it and then replace the `GAS_MANAGER_POLICY_ID` in the snippet below. -::: code-group - -```ts [sponsor-gas.ts] -import { provider } from "./provider.ts"; - -// Find your Gas Manager policy id at: // [!code focus:10] -//dashboard.alchemy.com/gas-manager/policy/create -const GAS_MANAGER_POLICY_ID = "YourGasManagerPolicyId"; - -// Link the provider with the Gas Manager. This ensures UOs -// sent with this provider get sponsorship from the Gas Manager. -provider.withAlchemyGasManager({ - policyId: GAS_MANAGER_POLICY_ID, -}); - -// Here's how to send a sponsored UO from your smart account: -const { hash } = await provider.sendUserOperation({ - target: "0xTargetAddress", - data: "0xCallData", - value: 0n, // value in bigint or leave undefined -}); -``` - -<<< @/snippets/aa-core/smartAccountClient.ts - -::: +<<< @/snippets/aa-alchemy/gas-manager-client.ts You've created a gas manager policy and linked it to the provider. This guarantees that UOs sent with this provider receive sponsorship if and only the UO satisfies the rules defined in your gas policy. @@ -91,17 +58,7 @@ Now you're ready to send sponsored UOs! You can send a UO by calling `sendUserOp ::: code-group ```ts [sponsor-gas.ts] -import { provider } from "./provider.ts"; - -// Your Gas Manager policy id is available at: // -//dashboard.alchemy.com/gas-manager/policy/create -const GAS_MANAGER_POLICY_ID = "YourGasManagerPolicyId"; - -// Link the provider with the Gas Manager so the UOs -// sent with this provider get sponsorship from the Gas Manager. -provider.withAlchemyGasManager({ - policyId: GAS_MANAGER_POLICY_ID, -}); +import { smartAccountClient } from "./smartAccountClient.ts"; // Send a sponsored UO from your smart account like this: // [!code focus:6] const { hash } = await provider.sendUserOperation({ @@ -111,7 +68,7 @@ const { hash } = await provider.sendUserOperation({ }); ``` -<<< @/snippets/aa-core/smartAccountClient.ts +<<< @/snippets/aa-alchemy/gas-manager-client.ts ::: diff --git a/site/tutorials/transferring-ownership.md b/site/using-smart-accounts/transfer-ownership/light-account.md similarity index 75% rename from site/tutorials/transferring-ownership.md rename to site/using-smart-accounts/transfer-ownership/light-account.md index 8fdf269263..cc2442e219 100644 --- a/site/tutorials/transferring-ownership.md +++ b/site/using-smart-accounts/transfer-ownership/light-account.md @@ -3,28 +3,28 @@ outline: deep head: - - meta - property: og:title - content: How to Transfer Ownership of a Smart Account + content: How to Transfer Ownership of a Light Account - - meta - name: description - content: Follow this guide to transfer ownership of a smart account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: Follow this guide to transfer ownership of a Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - meta - property: og:description - content: Follow this guide to transfer ownership of a smart account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: Follow this guide to transfer ownership of a Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. - - meta - name: twitter:title - content: How to Transfer Ownership of a Smart Account + content: How to Transfer Ownership of a Light Account - - meta - name: twitter:description - content: Follow this guide to transfer ownership of a smart account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. + content: Follow this guide to transfer ownership of a Light Account with Account Kit, a vertically integrated stack for building apps that support ERC-4337. next: text: Packages --- -# How to Transfer Ownership of a Smart Account +# How to Transfer Ownership of a Light Account Not all smart account implementations support transfering the owner (e.g. `SimpleAccount`). However, a number of the accounts in this guide and in Account Kit do, including our Light Account! Let's see a few different ways we can transfer ownership of an Account (using Light Account as an example). -## Light Account +## Usage Light Account exposes the following method which allows the existing owner to transfer ownership to a new address: @@ -39,14 +39,18 @@ There a number of ways you can call this method using Account Kit. ::: code-group ```ts [example.ts] -import { LightSmartContractAccount } from "@alchemy/aa-accounts"; -import { provider } from "./provider"; +import { transferLightAccountOwnership } from "@alchemy/aa-accounts"; +import { smartAccountClient } from "./smartAccountClient"; // this will return the address of the smart account you want to transfer ownerhip of const accountAddress = await provider.getAddress(); const newOwner = "0x..."; // the address of the new owner -const hash = LightSmartContractAccount.transferOwnership(provider, newOwner); // [!code focus:99] +// [!code focus:99] +const hash = transferLightAccountOwnership(smartAccountClient, { + newOwner, + waitForTxn: true, +}); ``` <<< @/snippets/aa-core/smartAccountClient.ts @@ -63,7 +67,7 @@ Assuming you have connected the `provider` to a `LightAccount` using `provider.c ```ts [example.ts] import { encodeFunctionData } from "viem"; -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // this will return the address of the smart account you want to transfer ownerhip of const accountAddress = await provider.getAddress(); diff --git a/site/using-smart-accounts/transfer-ownership/modular-account.md b/site/using-smart-accounts/transfer-ownership/modular-account.md new file mode 100644 index 0000000000..e69de29bb2