Skip to content

createModularAccountV2Client

Creates a Modular Account V2 client using the provided configuration parameters.

Import

import { createModularAccountV2Client } from "@account-kit/smart-contracts";

Usage

import { createModularAccountV2Client } from "@account-kit/smart-contracts";
import { LocalAccountSigner } from "@aa-sdk/core";
import { alchemy, sepolia } from "@account-kit/infra";
 
const MNEMONIC = "...";
const RPC_URL = "...";
 
const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
 
const chain = sepolia;
 
const transport = alchemy({ rpcUrl: RPC_URL });
 
const policyId = "...";
 
const modularAccountV2Client = await createModularAccountV2Client({
  chain,
  signer,
  transport,
  policyId, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!
});

Parameters

config

CreateModularAccountV2ClientParams The configuration parameters required to create the Modular Account v2 account client

Returns

Promise<SmartAccountClient> A promise that resolves to a SmartAccountClient instance