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

# Alchemy

This guide shows you how to use Dynamic as a signer for Alchemy Smart Accounts.

## Install the sdk

By default, the latest version of the Dynamic SDK ships with Viem. If you need to use Ethers, please refer to [this guide](/react-sdk/using-ethers).

<Tip>
  In this example, we are installing only the Ethereum connectors in order to
  keep bundle size light. If you need any others, you can find the references
  [here](react-sdk/providers/dynamiccontextprovider#walletconnectors).
</Tip>

```bash
npm i -s @dynamic-labs/sdk-react-core @dynamic-labs/ethereum
```

## Add Dynamic to your application

In order to use Dynamic, you should wrap your app with DynamicContextProvider at the highest possible level i.e.

```jsx
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core'
import { EthereumWalletConnectors } from '@dynamic-labs/ethereum'
import Home from './Home'

// Found in your Dynamic dashboard (https://app.dynamic.xyz/dashboard/developer/api)
const DYNAMIC_ENVIRONMENT_ID = 'XXXXX'

const App = () => {
  return (
    <div className="app">
      <DynamicContextProvider
        settings={{
          environmentId: DYNAMIC_ENVIRONMENT_ID,
          walletConnectors: [EthereumWalletConnectors],
        }}
      >
        <Home />
      </DynamicContextProvider>
    </div>
  )
}

export default App
```

## Create a SmartAccountSigner

Next, inside any component which is wrapped by the above DynamicContextProvider, use the useDynamicContext hook to fetch your provider, and create a SmartAccountSigner:

```tsx
import { WalletClientSigner, type SmartAccountSigner } from '@alchemy/aa-core'
import { useDynamicContext } from '@dynamic-labs/sdk-react-core'
import { isEthereumWallet } from '@dynamic-labs/ethereum'

// eslint-disable-next-line react-hooks/rules-of-hooks
const { primaryWallet } = useDynamicContext()

if (!isEthereumWallet(primaryWallet)) {
  throw new Error('This wallet is not a Ethereum wallet');
}

const dynamicProvider = await primaryWallet?.getWalletClient()

// a smart account signer you can use as an owner on ISmartContractAccount
export const dynamicSigner: SmartAccountSigner = new WalletClientSigner(
  dynamicProvider,
  'dynamic' // signer type
)
```

## Use it with Light Account

Let's see it in action with aa-alchemy and LightSmartContractAccount from aa-accounts:

<CodeGroup>
  ```tsx example.ts
  import { AlchemyProvider } from '@alchemy/aa-alchemy'
  import {
    LightSmartContractAccount,
    getDefaultLightAccountFactoryAddress,
  } from '@alchemy/aa-accounts'
  import { sepolia } from 'viem/chains'
  import { dynamicSigner } from './dynamic'

  const chain = sepolia

  const provider = new AlchemyProvider({
    apiKey: 'ALCHEMY_API_KEY',
    chain,
  }).connect(
    (rpcClient) =>
      new LightSmartContractAccount({
        chain,
        owner: dynamicSigner,
        factoryAddress: getDefaultLightAccountFactoryAddress(chain),
        rpcClient,
      })
  )
  ```

  ```tsx dynamic.ts
  import { WalletClientSigner, type SmartAccountSigner } from '@alchemy/aa-core'
  import { useDynamicContext } from '@dynamic-labs/sdk-react-core'
  import { isEthereumWallet } from '@dynamic-labs/ethereum'

  // eslint-disable-next-line react-hooks/rules-of-hooks
  const { primaryWallet } = useDynamicContext()

  if (!isEthereumWallet(primaryWallet)) {
    throw new Error('This wallet is not a Ethereum wallet');
  }

  const dynamicProvider = await primaryWallet?.getWalletClient()

  // a smart account signer you can use as an owner on ISmartContractAccount
  export const dynamicSigner: SmartAccountSigner = new WalletClientSigner(
    dynamicProvider,
    'dynamic' // signer type
  )
  ```
</CodeGroup>
