# Configure client

> Configure smart wallet client

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

<Info>`@alchemy/wallet-apis` (v5.x.x) is currently in beta but is the recommended replacement for `@account-kit/wallet-client` (v4.x.x). If you run into any issues, please [reach out](mailto:support@alchemy.com).</Info>

A smart wallet client is the main interface used to interact with smart wallets and take actions like sending transactions, batching transactions, swapping, sponsoring gas, and more.

## How it works

The `SmartWalletClient` extends viem's [Client](https://viem.sh/docs/clients/custom#build-your-own-client). By default, it uses [EIP-7702](/docs/wallets/transactions/using-eip-7702) to delegate the signer's EOA to a smart account, so the account address is the same as the signer address. No separate account deployment or address mapping is needed.

## Prerequisites

* [API key](https://dashboard.alchemy.com/apps)
* (Optional) [A gas policyID](https://dashboard.alchemy.com/gas-manager/policy/create)
* `@alchemy/wallet-apis` and `viem` installed (see the [quickstart](/docs/wallets/quickstart))

## Implementation

<Tabs>
  <Tab title="JavaScript" language="typescript">
    Use the [`createSmartWalletClient`](/docs/wallets/reference/wallet-apis/functions/createSmartWalletClient) function to create a smart wallet client.

    1. Replace the placeholders:
       * API key from your [Alchemy dashboard](https://dashboard.alchemy.com/apps)
       * Policy ID from your [gas policy](https://dashboard.alchemy.com/gas-manager/policy/create)
       * Signer from [authentication](/docs/wallets/authentication/login-methods/email-otp#step-4-check-authentication-status) or your own signer
    2. Create the client using `createSmartWalletClient` — the client defaults to EIP-7702 using the signer's address

    ```ts twoslash title="client.ts"
    import { privateKeyToAccount } from "viem/accounts";
    import { arbitrumSepolia } from "viem/chains";
    import {
      createSmartWalletClient,
      alchemyWalletTransport,
    } from "@alchemy/wallet-apis";

    export const client = createSmartWalletClient({
      transport: alchemyWalletTransport({ apiKey: "your-alchemy-api-key" }),
      chain: arbitrumSepolia,
      signer: privateKeyToAccount("0x-your-wallet-private-key"),
      paymaster: { policyId: "your-policy-id" },
    });
    ```
  </Tab>

  <Tab title="API" language="bash">
    When using the wallet [API](/docs/wallets/quickstart), you don't need to define a client - send requests directly to the API endpoints.
  </Tab>
</Tabs>

<Accordion title="Using @account-kit/wallet-client (v4.x.x)?">
The examples on this page use `@alchemy/wallet-apis` (v5.x.x). If you're using `@account-kit/wallet-client` (v4.x.x), the client setup looks like this:

```ts title="client.ts (v4.x.x)"
import { LocalAccountSigner } from "@aa-sdk/core";
import { createSmartWalletClient } from "@account-kit/wallet-client";
import { alchemy, sepolia } from "@account-kit/infra";

const signer = LocalAccountSigner.privateKeyToAccountSigner("0xYOUR_PRIVATE_KEY" as const);

export const client = createSmartWalletClient({
  transport: alchemy({ apiKey: "YOUR_API_KEY" }),
  chain: sepolia,
  signer,
  account: signer.address, // can also be passed per action as `from` or `account`
  // Optional: sponsor gas for your users (see "Sponsor gas" guide)
  policyId: "YOUR_POLICY_ID", 
});
```

Key v4.x.x differences:
* **Account address** must be specified on the client or per action (`from` or `account`). In v5.x.x, the client automatically uses the owner's address as the account address via [EIP-7702](/docs/wallets/transactions/using-eip-7702).
* **Chain imports** come directly from `@account-kit/infra` instead of `viem/chains`.
* **Numeric values** use hex strings: `value: "0x0"` instead of `value: BigInt(0)`.
* In v4.x.x, the **paymaster capability** on `prepareCalls` or `sendCalls` is called `paymasterService` instead of `paymaster`, or you can set the `policyId` directly on the client.
* **Owners** use `LocalAccountSigner` / `WalletClientSigner` from `@aa-sdk/core`. In v5.x.x, a viem `LocalAccount` or `WalletClient` is used directly.

See the [full migration guide](/docs/wallets/resources/migration-v5) for a complete cheat sheet.
</Accordion>


## Advanced

<Accordion title="Use a non-7702 smart account">
  By default, the client uses EIP-7702 with the signer's address. If you need to use a standalone smart account instead, see the [non-7702 mode guide](/docs/wallets/transactions/using-eip-7702#how-to-use-non-7702-mode).

  Learn more about the different smart account types [here](/docs/wallets/smart-contracts/choosing-a-smart-account).
</Accordion>

<Accordion title="Connect to an existing non-7702 account">
  By default, the client uses the signer's address with EIP-7702. If you already know a [non-7702 smart account](/docs/wallets/transactions/using-eip-7702#how-to-use-non-7702-mode) address your signer owns (either from calling `requestAccount` or stored from a previous session), you can pass it when creating the client or on each action.

  **On the client:**

  ```ts
  const client = createSmartWalletClient({
    // ... your config
    account: "0xYOUR_SCA_ADDRESS",
  });
  ```

  **Per action:**

  ```ts
  await client.sendCalls({
    account: "0xYOUR_SCA_ADDRESS",
    calls: [...],
  });
  ```
</Accordion>

<Accordion title="Extend client with custom actions">
  The `SmartWalletClient` is a viem client extension, so it supports the `.extend` method for adding custom actions. For example, experimental swap actions are added this way:

  ```ts
  import { swapActions } from "@alchemy/wallet-apis/experimental";

  const swapClient = client.extend(swapActions);
  ```
</Accordion>

<Accordion title="Use one client for multiple accounts">
  If the same signer owns multiple [non-7702 smart accounts](/docs/wallets/transactions/using-eip-7702#how-to-use-non-7702-mode), you can use a single client to interact with any of them by passing `account` on each action:

  ```ts
  // Two SCAs owned by the same signer, created via requestAccount
  const treasuryAccount = "0xaaa...111";
  const operationsAccount = "0xbbb...222";

  await client.sendCalls({
    account: treasuryAccount,
    calls: [{ to: "0x...", data: "0x", value: BigInt(0) }],
  });

  await client.sendCalls({
    account: operationsAccount,
    calls: [{ to: "0x...", data: "0x", value: BigInt(0) }],
  });
  ```

  If different signers are involved, use the prepare/sign/send flow with separate clients per signer instead.
</Accordion>

## Next Steps

* [Send transactions](/docs/wallets/transactions/send-transactions)
* [Sponsor gas](/docs/wallets/transactions/sponsor-gas)
* [Batch transactions](/docs/wallets/transactions/send-batch-transactions)