createLightAccountClient
createLightAccountClient
is a factory that improves the developer experience of connecting a Light Account to a SmartAccountClient
. You can use this to directly instantiate a SmartAccountClient
already connected to a Light Account in one line of code.
Usage
smartAccountClient.ts
import { createLightAccountClient } from "@alchemy/aa-accounts";
import { LocalAccountSigner, sepolia } from "@alchemy/aa-core";
import { http } from "viem";
export const smartAccountClient = await createLightAccountClient({
transport: http("RPC_URL"),
chain: sepolia,
account: {
signer: LocalAccountSigner.mnemonicToAccountSigner("OWNER_MNEMONIC"),
},
});
Returns
Promise<SmartAccountClient>
A Promise
containing a new SmartAccountClient
connected to a Light Account.
Parameters
config: CreateLightAccountClientParams
-
transport: Transport
-- a Viem Transport for interacting with JSON RPC methods. -
chain: Chain
-- the chain on which to create the client. -
account
: CreateLightAccountParams -- additional parameters to pass to thecreateLightAccount
. Notably, asigner
field of typeSmartAccountSigner
is required. -
...clientParams
-- [optional] additional parameters to pass to theSmartAccountClient
constructor.