createModularAccountV2Client

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

Example

import { 
function createModularAccountV2Client<TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner<any>>(args: CreateModularAccountV2AlchemyClientParams<AlchemyTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>> (+1 overload)
createModularAccountV2Client
} from "@account-kit/smart-contracts";
import {
class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>

Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.

LocalAccountSigner
} from "@aa-sdk/core";
import {
function alchemy(config: AlchemyTransportConfig): AlchemyTransport

Creates an Alchemy transport with the specified configuration options. When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt. If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.

alchemy
,
const sepolia: Chain
sepolia
} from "@account-kit/infra";
const
const MNEMONIC: "..."
MNEMONIC
= "...";
const
const RPC_URL: "..."
RPC_URL
= "...";
const
const signer: LocalAccountSigner<{ address: Address; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: Hash; }) => Promise<Hex>; ... 7 more ...; getHdKey: () => HDKey; }>
signer
=
class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>

Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.

LocalAccountSigner
.
LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>.mnemonicToAccountSigner(key: string, opts?: HDOptions): LocalAccountSigner<HDAccount>

Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.

mnemonicToAccountSigner
(
const MNEMONIC: "..."
MNEMONIC
);
const
const chain: Chain
chain
=
const sepolia: Chain
sepolia
;
const
const transport: AlchemyTransport
transport
=
function alchemy(config: AlchemyTransportConfig): AlchemyTransport

Creates an Alchemy transport with the specified configuration options. When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt. If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.

alchemy
({
rpcUrl: string
rpcUrl
:
const RPC_URL: "..."
RPC_URL
});
const
const policyId: "..."
policyId
= "...";
const
const modularAccountV2Client: { [x: string]: unknown; account: ModularAccountV2<LocalAccountSigner<{ address: Address; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: Hash; }) => Promise<Hex>; ... 7 more ...; getHdKey: () => HDKey; }>>; ... 84 more ...; extend: <const client extends { ...; } & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>; }
modularAccountV2Client
= await
createModularAccountV2Client<Chain, LocalAccountSigner<{ address: Address; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: Hash; }) => Promise<Hex>; ... 7 more ...; getHdKey: () => HDKey; }>>(args: CreateModularAccountV2AlchemyClientParams<...>): Promise<...> (+1 overload)
createModularAccountV2Client
({
chain: { blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; ... 7 more ...; testnet?: boolean | undefined; } & ChainConfig<...>

Chain for the client.

chain
,
signer: LocalAccountSigner<{ address: Address; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: Hash; }) => Promise<Hex>; ... 7 more ...; getHdKey: () => HDKey; }>
signer
,
transport: AlchemyTransport

The RPC transport

transport
,
policyId?: string | string[] | undefined
policyId
, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!
});

Param

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

Call Signature

1function createModularAccountV2Client<TChain, TSigner>(
2 args,
3): Promise<AlchemySmartAccountClient<TChain, ModularAccountV2<TSigner>>>;

Defined in: account-kit/smart-contracts/src/ma-v2/client/client.ts:88

Type Parameters

Type ParameterDefault type

TChain extends Chain

Chain

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

Parameters

Returns

Promise<AlchemySmartAccountClient<TChain, ModularAccountV2<TSigner>>>

Call Signature

1function createModularAccountV2Client<TTransport, TChain, TSigner>(
2 args,
3): Promise<ModularAccountV2Client<TSigner, TChain, TTransport>>;

Defined in: account-kit/smart-contracts/src/ma-v2/client/client.ts:99

Type Parameters

Type ParameterDefault type

TTransport extends Transport

Transport

TChain extends Chain

Chain

TSigner extends SmartAccountSigner<any>

SmartAccountSigner<any>

Parameters

ParameterType

args

CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>

Returns

Promise<ModularAccountV2Client<TSigner, TChain, TTransport>>

Call Signature

1function createModularAccountV2Client<TTransport, TChain>(
2 args,
3): Promise<WebauthnModularAccountV2Client<TChain, TTransport>>;

Defined in: account-kit/smart-contracts/src/ma-v2/client/client.ts:107

Type Parameters

Type ParameterDefault type

TTransport extends Transport

Transport

TChain extends Chain

Chain

Parameters

ParameterType

args

CreateWebauthnModularAccountV2ClientParams<TTransport, TChain>

Returns

Promise<WebauthnModularAccountV2Client<TChain, TTransport>>