Skip to content

Commit

Permalink
docs: update address calculation, session key, and guides (alchemypla…
Browse files Browse the repository at this point in the history
…tform#451)

* docs: update address calculation, session key, and guides

- fix signer typos
- add address calculation information to LA and MA
- update session key tag to use keccak algorithm
- improve MA getting started guide for better flow

* Update site/smart-accounts/light-account/index.md

Co-authored-by: Michael Moldoveanu <[email protected]>

* Update site/smart-accounts/light-account/index.md

Co-authored-by: Dennis Won <[email protected]>

* Update site/snippets/session-keys/add-session-key.ts

Co-authored-by: Dennis Won <[email protected]>

* docs: fix aa core definition

* docs: address modular account getting started PR comment

Co-authored-by: Dennis Won <[email protected]>

---------

Co-authored-by: Dennis Won <[email protected]>
Co-authored-by: Michael Moldoveanu <[email protected]>
  • Loading branch information
3 people authored Feb 15, 2024
1 parent ab15676 commit 6fd817f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
2 changes: 2 additions & 0 deletions site/packages/aa-accounts/light-account/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ A Promise containing a new `LightAccount`.

- `initCode: Hex` -- [optional] the initCode for deploying the smart account with which the client will connect.

- `salt: bigint` -- [optional] a value that is added to the address calculation to allow for multiple accounts for the same owner. The default value supplied is `0n`. To see this calculation used in the smart contract, check out [the LightAccountFactory](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccountFactory.sol#L30).

- `accountAddress: Address` -- [optional] a smart account address override that this object will manage instead of generating its own.

- `version: LightAccountVersion` -- [optional] the LightAccount contract version. Default: [v1.1.0](https://github.com/alchemyplatform/light-account/releases/tag/v1.1.0)
Expand Down
4 changes: 2 additions & 2 deletions site/packages/aa-signers/capsule/authenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ A Promise containing the `CapsuleUserInfo`, an `Record<string, Wallet>` where Wa

- `signer: string` -- Capsule Signer information.

- `address: string` -- [optional] EOA address of the Capusle Signer.
- `address: string` -- [optional] EOA address of the Capsule Signer.

- `publicKey: string` -- [optional] Public Key of the Capusle Signer.
- `publicKey: string` -- [optional] Public Key of the Capsule Signer.

- `scheme: WalletScheme` -- [optional] either `CGGMP` or `DKLS`.
6 changes: 6 additions & 0 deletions site/smart-accounts/light-account/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ The code snippet below demonstrates how to use Light Account with Account Kit. I

::: code-group

::: tip Address calculation
For the Light Account, the address of the smart account will be calculated as a combination of [the owner and the salt](https://github.com/alchemyplatform/light-account/blob/main/src/LightAccountFactory.sol#L24-L33). You will get the same smart account address each time you supply the same `owner`. You can also optionally supply `salt` if you want a different address for the same owner (the default salt is `0n`).

If you already have an account with a new or different owner (transferred ownership), you can supply the `accountAddress` to connect with your account with a new owner. In that case, the `owner` is not used for address calculation, but still used for signing the operation.
:::

## [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:
Expand Down
48 changes: 44 additions & 4 deletions site/smart-accounts/modular-account/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,62 @@ head:

# Getting started with Modular Account

Getting started with Modular Account is really simple, especially if you are using `@alchemy/aa-alchemy`.
It's easy to get started with Modular Account! We'll show you two different ways using `@alchemy/aa-alchemy` and `@alchemy/aa-core`.

::: tip Choosing your package
The [`aa-core`](/packages/aa-core/) package is not opinionated about your RPC provider. As a result, creating a client requires more configuration. If you don't need this extra flexibility, [`aa-alchemy`](/packages/aa-alchemy/) is much easier to jump in with, as you'll see below.
:::

## With `@alchemy/aa-alchemy`

When using `@alchemy/aa-alchemy` it is really easy to get started simply do the following:
### Install packages

::: code-group

```bash [npm]
npm i @alchemy/aa-alchemy @alchemy/aa-core
```

```bash [yarn]
yarn add @alchemy/aa-alchemy @alchemy/aa-core
```

:::

### Create a client

Then you can simply do the following:

<<< @/snippets/aa-alchemy/connected-client.ts

::: tip Address calculation
For the Modular Account, the address of the smart account will be calculated as a combination of [several variables](https://github.com/alchemyplatform/modular-account/blob/74fe1bfa056bbd41c933990fca0598c8cc3e90e8/src/factory/MultiOwnerModularAccountFactory.sol#L66-L71). You will get the same smart account address each time you supply the same `owner` or `owners`. You can also optionally supply `salt` if you want a different address for the same owner(s) (the default salt is `0n`).

If you already have an account with a new or different owner (transferred ownership), you can supply the `accountAddress` to connect with your account with a new owner. In that case, the `owner` is not used for address calculation, but still used for signing the operation.
:::

That's it! You've configured your client.

Next, if you want to replace that `owner` with a smart account signer, check out [choosing a signer](/signers/choosing-a-signer). Or, if you're ready to get onchain, go to [send user operations](/using-smart-accounts/send-user-operations).

## With `@alchemy/aa-core`

### Install packages

If you are using `@alchemy/aa-core` you'll want to also add `@alchemy/aa-accounts` to get the Smart Account factory for Modular Account.

```bash
yarn add @alchemy/aa-core @alchemy/aa-accounts
::: code-group

```bash [npm]
npm i @alchemy/aa-core @alchemy/aa-accounts viem
```

```bash [yarn]
yarn add @alchemy/aa-core @alchemy/aa-accounts viem
```

:::

### Create a client

Then you'll need to create a `SmartAccountClient`
Expand Down Expand Up @@ -73,3 +111,5 @@ const decoratedClient = smartAccountClient

<<< @/snippets/aa-core/smartAccountClient.ts
:::

Next, if you want to replace that `owner` with a smart account signer, check out [choosing a signer](/signers/choosing-a-signer). Or, if you're ready to get onchain, go to [send user operations](/using-smart-accounts/send-user-operations).
4 changes: 3 additions & 1 deletion site/snippets/session-keys/add-session-key.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { SessionKeyPermissionsBuilder } from "@alchemy/aa-accounts";
import { client } from "./base-client.js";
import { keccak256 } from "viem";

const result = await client.addSessionKey({
key: "0xSessionKeyAddress",
tag: "0xkeytag",
// tag is an identifier for the emitted SessionKeyAdded event
tag: keccak256(new TextEncoder().encode("session-key-tag")),
permissions: new SessionKeyPermissionsBuilder().encode(),
});

0 comments on commit 6fd817f

Please sign in to comment.