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.

Examples

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

Param

The parameters for creating a light account client

Call Signature

1function createLightAccountClient<TSigner>(
2 params,
3): Promise<
4 AlchemySmartAccountClient<
5 undefined | Chain,
6 LightAccount<TSigner>,
7 LightAccountClientActions<TSigner>
8 >
9>;

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

Type Parameters

Type ParameterDefault type

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

Parameters

ParameterType

params

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

Returns

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

Call Signature

1function createLightAccountClient<TChain, TSigner, TTransport>(
2 args,
3): Promise<
4 SmartAccountClient<
5 CustomTransport,
6 TChain,
7 LightAccount<TSigner>,
8 SmartAccountClientActions<Chain, SmartContractAccount> &
9 LightAccountClientActions<TSigner, LightAccount<TSigner>>
10 >
11>;

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

Type Parameters

Type ParameterDefault type

TChain extends undefined | Chain

undefined | Chain

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

TTransport extends Transport

Transport

Parameters

ParameterType

args

object & Omit<CreateLightAccountParams<TTransport, TSigner>, "chain" | "transport"> & Omit<{ account?: SmartContractAccount; addBreadCrumb?: <T>(crumb) => T; cacheTime?: number; chain?: Chain | TChain; customMiddleware?: ClientMiddlewareFn<undefined | UserOperationContext>; dummyPaymasterAndData?: ClientMiddlewareFn<undefined | UserOperationContext>; feeEstimator?: ClientMiddlewareFn<undefined | UserOperationContext>; gasEstimator?: ClientMiddlewareFn<undefined | UserOperationContext>; key?: string; name?: string; opts?: { feeOptions?: { callGasLimit?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; maxFeePerGas?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; maxPriorityFeePerGas?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; paymasterPostOpGasLimit?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; paymasterVerificationGasLimit?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; preVerificationGas?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; verificationGasLimit?: { max?: number | bigint | `0x${(...)}`; min?: number | bigint | `0x${(...)}`; multiplier?: number; }; }; txMaxRetries?: number; txRetryIntervalMs?: number; txRetryMultiplier?: number; }; paymasterAndData?: ClientMiddlewareFn<undefined | UserOperationContext>; pollingInterval?: number; signUserOperation?: ClientMiddlewareFn<undefined | UserOperationContext>; transport: TTransport; type?: string; userOperationSimulator?: ClientMiddlewareFn<undefined | UserOperationContext>; }, "account" | "chain" | "transport"> & NotType<TTransport, AlchemyTransport>

Returns

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