Skip to content
Alchemy Logo

createLightAccountClient

Creates a light account client using the provided parameters, including account information, transport mechanism, blockchain chain, and additional client configurations. This function first creates a light account and then uses it to create a smart account client, extending it with light account client actions.

Also, we modified the return type to be the light account alchemy client if the transport is alchemy.

import { createLightAccountClient } from "@account-kit/smart-contracts";
import { LocalAccountSigner } from "@aa-sdk/core";
import { sepolia } from "viem/chains";
import { http, generatePrivateKey } from "viem";
 
const account = await createLightAccountClient({
  chain: sepolia,
  transport: http("RPC_URL"),
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});
import { createLightAccountClient } from "@account-kit/smart-contracts";
import { sepolia, alchemy } from "@account-kit/infra";
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem";
 
const lightAlchemyAccountClient = await createLightAccountClient({
  transport: alchemy({ apiKey: "your-api-key" }),
  chain: sepolia,
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

The parameters for creating a light account client

function createLightAccountClient<TSigner>(
  params,
): Promise<
  AlchemySmartAccountClient<
    undefined | Chain,
    LightAccount<TSigner>,
    LightAccountClientActions<TSigner>
  >
>;

Defined in: account-kit/smart-contracts/src/light-account/clients/client.ts:41

Type ParameterDefault type

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

ParameterType

params

Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>, "account"> & object

Promise<AlchemySmartAccountClient<undefined | Chain, LightAccount<TSigner>, LightAccountClientActions<TSigner>>>

function createLightAccountClient<TChain, TSigner, TTransport>(
  args,
): Promise<
  SmartAccountClient<
    CustomTransport,
    TChain,
    LightAccount<TSigner>,
    SmartAccountClientActions<Chain, SmartContractAccount> &
      LightAccountClientActions<TSigner, LightAccount<TSigner>>
  >
>;

Defined in: account-kit/smart-contracts/src/light-account/clients/client.ts:54

Type ParameterDefault type

TChain extends undefined | Chain

undefined | Chain

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

TTransport extends Transport

Transport

ParameterType

args

object & Omit<CreateLightAccountParams<TTransport, TSigner>, "chain" | "transport"> & Omit<{ }, "account" | "chain" | "transport"> & NotType<TTransport, AlchemyTransport>

Promise<SmartAccountClient<CustomTransport, TChain, LightAccount<TSigner>, SmartAccountClientActions<Chain, SmartContractAccount> & LightAccountClientActions<TSigner, LightAccount<TSigner>>>>

Was this page helpful?