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

# toSessionClient

> Function to create an AbstractClient using a session key.

The `toSessionClient` function creates a new `SessionClient` instance that can submit transactions and perform actions (e.g. [writeContract](/abstract-global-wallet/agw-client/actions/writeContract)) from the Abstract Global wallet signed by a session key.

If a transaction violates any of the session key’s policies, it will be rejected.

## Usage

```tsx theme={null}
import { useAbstractClient } from "@abstract-foundation/agw-react";
import { parseAbi } from "viem";
import { abstractTestnet } from "viem/chains";
import { useAccount } from "wagmi";

export default function Example() {
    const { address } = useAccount();
    const { data: agwClient } = useAbstractClient();

    async function sendTransactionWithSessionKey() {
        if (!agwClient || !address) return;

        // Use the existing session signer and session that you created with useCreateSession
        // Likely you want to store these inside a database or solution like AWS KMS and load them
        const sessionClient = agwClient.toSessionClient(sessionSigner, session);

        const hash = await sessionClient.writeContract({
            abi: parseAbi(["function mint(address,uint256) external"]),
            account: sessionClient.account,
            chain: abstractTestnet,
            address: "0xC4822AbB9F05646A9Ce44EFa6dDcda0Bf45595AA",
            functionName: "mint",
            args: [address, BigInt(1)],
        });
    }

    return <button onClick={sendTransactionWithSessionKey}>Send Transaction with Session Key</button>;
}
```

## Parameters

<ResponseField name="sessionSigner" type="Account" required>
  The account that will be used to sign transactions. This must match the signer address specified in the session configuration.
</ResponseField>

<ResponseField name="session" type="SessionConfig" required>
  The session configuration created by [createSession](/abstract-global-wallet/agw-client/session-keys/createSession).
</ResponseField>

## Returns

<ResponseField name="sessionClient" type="AbstractClient">
  A new AbstractClient instance that uses the session key for signing transactions. All transactions will be validated against the session's policies.
</ResponseField>
