> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# createKernelClientForWalletAccount

# createKernelClientForWalletAccount

Creates a ZeroDev KernelClient instance for a given smart wallet account. The KernelClient allows you to send user operations and interact with the smart account.

## Usage

```javascript theme={"system"}
import { createKernelClientForWalletAccount } from "@dynamic-labs-sdk/zerodev";
import { isEvmWalletAccount } from "@dynamic-labs-sdk/evm";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isEvmWalletAccount(walletAccount)) {
  const kernelClient = await createKernelClientForWalletAccount({
    smartWalletAccount: walletAccount,
  });

  // Use the kernel client to send transactions
  const txHash = await kernelClient.sendTransaction({
    to: recipientAddress,
    value: parseEther("0.01"),
    data: "0x",
  });
}
```

## Parameters

| Parameter            | Type                                     | Description                                                                                                                                                                                                                                                |
| -------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `smartWalletAccount` | `EvmWalletAccount`                       | The smart wallet account to create the KernelClient for                                                                                                                                                                                                    |
| `withSponsorship`    | `boolean` (optional)                     | Whether to use gas sponsorship. Defaults to `true`                                                                                                                                                                                                         |
| `networkId`          | `string` (optional)                      | The network ID to use. If not provided, uses the active network                                                                                                                                                                                            |
| `bundlerProvider`    | `ZerodevBundlerProvider` (optional)      | A custom bundler provider                                                                                                                                                                                                                                  |
| `bundlerRpc`         | `string` (optional)                      | A custom bundler RPC URL                                                                                                                                                                                                                                   |
| `paymasterRpc`       | `string` (optional)                      | A custom paymaster RPC URL                                                                                                                                                                                                                                 |
| `gasTokenAddress`    | `Hex` (optional)                         | Address of an ERC20 token to use for gas payments                                                                                                                                                                                                          |
| `eip7702Auth`        | `SignAuthorizationReturnType` (optional) | A pre-signed EIP-7702 authorization. When provided, the kernel client uses this authorization instead of signing a new one internally. Useful for singleUse MFA flows where you need to separate the authorization signing step from the transaction step. |
| `client`             | `DynamicClient` (optional)               | The Dynamic client instance. Only required when using multiple clients.                                                                                                                                                                                    |

## Returns

`Promise<KernelClient>` - A promise that resolves to a ZeroDev KernelClient instance.

## Examples

### With gas sponsorship (default)

```javascript theme={"system"}
const kernelClient = await createKernelClientForWalletAccount({
  smartWalletAccount: walletAccount,
});
```

### Without gas sponsorship

```javascript theme={"system"}
const kernelClient = await createKernelClientForWalletAccount({
  smartWalletAccount: walletAccount,
  withSponsorship: false,
});
```

### With custom gas token (ERC20)

```javascript theme={"system"}
const kernelClient = await createKernelClientForWalletAccount({
  smartWalletAccount: walletAccount,
  gasTokenAddress: "0x...", // USDC address
});
```

### With specific network

```javascript theme={"system"}
const kernelClient = await createKernelClientForWalletAccount({
  smartWalletAccount: walletAccount,
  networkId: "137", // Polygon
});
```

### With pre-signed EIP-7702 authorization

This is useful for singleUse MFA flows where you need to separate the authorization signing step from the transaction step:

```javascript theme={"system"}
import { signEip7702Authorization } from "@dynamic-labs-sdk/zerodev";

// First, sign the authorization separately
const eip7702Auth = await signEip7702Authorization({
  smartWalletAccount: walletAccount,
});

// Then create the kernel client with the pre-signed authorization
const kernelClient = await createKernelClientForWalletAccount({
  smartWalletAccount: walletAccount,
  eip7702Auth,
});
```

## React

Create the kernel client inside a button handler or `useEffect` — it should not be created at module level as it depends on runtime wallet state:

```tsx theme={"system"}
import { createKernelClientForWalletAccount, sendUserOperation } from '@dynamic-labs-sdk/zerodev';
import { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';
import { parseEther } from 'viem';

function AdvancedSendButton({ recipientAddress }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isEvmWalletAccount);
  const [txHash, setTxHash] = useState('');

  const handleSend = async () => {
    if (!walletAccount) return;

    const kernelClient = await createKernelClientForWalletAccount({
      smartWalletAccount: walletAccount,
    });

    const txHash = await kernelClient.sendTransaction({
      to: recipientAddress,
      value: parseEther('0.01'),
      data: '0x',
    });

    setTxHash(txHash);
  };

  return (
    <div>
      <button onClick={handleSend} disabled={!walletAccount}>Send via Kernel</button>
      {txHash && <p>Tx hash: {txHash}</p>}
    </div>
  );
}
```

## Related functions

* [signEip7702Authorization](/javascript/reference/zerodev/sign-eip-7702-authorization) - Sign an EIP-7702 authorization for ZeroDev kernel delegation
* [canSponsorTransaction](/javascript/reference/zerodev/can-sponsor-user-operation) - Check if a transaction can be sponsored
* [estimateTransactionGas](/javascript/reference/zerodev/estimate-user-operation-gas) - Estimate gas for a transaction
* [getSignerForSmartWalletAccount](/javascript/reference/zerodev/get-signer-for-smart-wallet-account) - Get the signer for a smart wallet
