Skip to content

Commit

Permalink
docs: faq upgrade from simple to light account instructions (alchemyp…
Browse files Browse the repository at this point in the history
…latform#449)

* docs: feat: update session key abi

* docs: faq upgrade from simple to light account instructions

* fix: add uups upgrade to and call link to the faq doc

---------

Co-authored-by: Dennis Won <[email protected]>
  • Loading branch information
avarobinson and denniswon authored Feb 15, 2024
1 parent 10a1b85 commit 7e48e13
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions site/resources/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ It is unlikely you will need to frequently update the Light Account contract its
Yes! The optional index value (salt) on Light Account enables the ability to have multiple accounts for the same owner address. This value defaults to 0. You can set it when you create [light account](/packages/aa-accounts/light-account/).
:::

### How can I upgrade from Simple Account to Light Account?

::: details Answer
[Simple Account's](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol) support [`upgradeToAndCall`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/4e7e6e54daedf091d91f2f2df024cbb8f253e2ef/contracts/proxy/utils/UUPSUpgradeable.sol#L86) implemented by openzeppelin’s [UUPSUpgradeable](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) contract. This allows you to upgrade from Simple Account to Light Account without changing the smart contract account address. Using `upgradeToAndCall` will update the underlying implementation contract on the account while the account address and assets will stay the same.

You can call `upgradeToAndCall` on the Simple Account with these params:

- `newImplementation`: Latest LightAccount implementation address (found [here](https://github.com/alchemyplatform/light-account/blob/main/Deployments.md#lightaccount) - make sure to use the implementation address, not the factory address)
- For example LightAccount v1.1.0 - 0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba
- `data`: encoded version of the `initialize` function with `anOwner` parameter set to the owner/signer on the account, usually the same owner as what the account used as Simple Account.
- In solidity (foundry) you can use abi.encodeCall and in viem you can use [encodeFunctionData](https://github.com/alchemyplatform/light-account/blob/main/Deployments.md#lightaccount)

It is very important that the `initialize` step is encoded correctly to ensure the account does not get in to a risky state where someone else could call initialize on it and reassign and a signer. You can call `owner()` on the account after upgrade to make sure it is assigned correctly.

This can be called on the existing smart contract account by sending a user operation that calls `execute` (or `executeBatch`) and have that call `upgradeToAndCall` (the same way you would make the account send calls to other addresses).
:::

## Submitting `UserOperation`s

### How does the speed of `UserOperation`s compare to normal transactions?
Expand Down

0 comments on commit 7e48e13

Please sign in to comment.