Light Account • Getting started
It is easy to get started with Light Account! We will show you how to create and send user operations for both LightAccount
and MultiOwnerLightAccount
using @alchemy/aa-alchemy
.
Install packages
Prerequisites
- minimum Typescript version of 5
- pin viem to 2.20.0 (
yarn add [email protected]
)
Installation
Create a client and send a user operation
The code snippets below demonstrate how to use LightAccount
and MultiOwnerLightAccount
with Account Kit. They create the account and send a UserOperation
from it.
Address calculation
For LightAccount
, the address of the smart account will be calculated as a combination of the version, the owner, and the salt. You will get the same smart account address each time you supply the same version
and owner
. Alternatively, you can supply salt
if you want a different address for the same version
and owner
params (the default salt is 0n
). For MultiOwnerLightAccount
, the same pattern follows, except that it takes an array of owner addresses instead of a single owner address.
If you want to use a signer to connect to an account whose address does not map to the contract-generated address, you can supply the accountAddress
to connect with the account of interest. In that case, the signer
address is not used for address calculation, but only used for signing the operation.
Reference: https://eips.ethereum.org/EIPS/eip-4337#first-time-account-creation