Skip to content

Commit

Permalink
docs: add docs for using and contributing custom accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed Feb 1, 2024
1 parent 3d4c707 commit 24cf8cd
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 117 deletions.
7 changes: 4 additions & 3 deletions site/.vitepress/sidebar/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion site/getting-started/deploy-an-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion site/overview/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 2 additions & 2 deletions site/overview/package-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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`.

Expand Down
66 changes: 0 additions & 66 deletions site/smart-accounts/accounts/guides/using-your-own.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ 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

You'll want to add documentation about your smart account so that developers can easily use your implementation in Account Kit. Below, we recommend adding documentation about your smart account's APIs, as well.

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

Expand Down
42 changes: 42 additions & 0 deletions site/smart-accounts/custom/using-your-own.md
Original file line number Diff line number Diff line change
@@ -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.

<!--@include: ../../packages/aa-core/accounts/index.md{21,58}-->

## `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
:::
25 changes: 25 additions & 0 deletions site/smart-accounts/gas-benchmarks.md
Original file line number Diff line number Diff line change
@@ -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 |
2 changes: 1 addition & 1 deletion site/smart-accounts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 24cf8cd

Please sign in to comment.