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

# Smart accounts

Create and manage smart accounts for your users with just a few lines of code, using our smart account feature. Additionally, smart accounts offer enhanced control and programmability, enabling features like those listed below.

- Gas Abstraction: Cover transaction fees for users, or allow users to pay for their own transactions using ERC-20 tokens.
- Batch Transactions: Perform multiple transactions in a single call.
- Automated Transactions: Allow users to automate actions, like swapping ETH to USDT when ETH hits $4,000.
- Set Spending Limits: Allow users to set tailored spending limits.

Our smart account integration streamlines your setup, allowing you to create and manage smart accounts using your favorite libraries like Viem, Ethers, and Wagmi. With this, you don't need to rely on third party packages to effortlessly create ERC-4337 compatible Smart Contract Wallets (SCWs), and give users the ability to perform batch transactions and efficiently manage gas sponsorship.

Embedded Wallet's smart account feature gives you the flexibility to configure your bundler client, and integrate with your paymaster. For more insights into how ERC-4337 works and its components, [check out our detailed blog post](https://blog.web3auth.io/an-ultimate-guide-to-web3-wallets-externally-owned-account-and-smart-contract-wallet/#introduction-to-eip-4337).

note

This is a paid feature and the minimum [pricing plan](https://web3auth.io/pricing.html) to use this SDK in a production environment is the **Growth Plan**. You can use this feature in Web3Auth Sapphire Devnet network for free.

## Enable smart accounts

Enable and configure smart accounts (account type, bundler, and paymaster for each chain) in your project on the [Embedded Wallets dashboard](https://developer.metamask.io/). The SDK reads this configuration during initialization, so no code change is needed.

To override the dashboard settings, pass `accountAbstractionConfig` in `web3AuthOptions`. Values you pass are merged with the dashboard configuration. Set `accountAbstractionConfig` to `null` to turn smart accounts off in your app even when they're enabled on the dashboard.

web3authConfig.ts

```typescript
import {
  WEB3AUTH_NETWORK,
  type AccountAbstractionConfig,
  type Web3AuthContextConfig,
} from '@web3auth/react-native-sdk'

const aaConfig: AccountAbstractionConfig = {
  smartAccountType: 'safe',
}

const web3AuthConfig: Web3AuthContextConfig = {
  web3AuthOptions: {
    clientId: '<YOUR_CLIENT_ID>',
    redirectUrl: 'yourapp://auth',
    network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
    accountAbstractionConfig: aaConfig,
  },
}

export default web3AuthConfig

```

Each smart account chain needs a bundler URL and a matching entry in `chains` (or on the dashboard). Initialization fails if a smart account chain has no bundler URL or chain configuration.

Toggle smart accounts at runtime

`Web3AuthProvider` creates a new SDK instance when `config` changes. To switch between smart accounts and an externally owned account (EOA), build the config from state and pass a new `key`so the provider remounts:

```tsx
const [useAA, setUseAA] = useState(false)
const config = useMemo(() => getWeb3AuthConfig(useAA), [useAA])

return (
  <Web3AuthProvider
    key={useAA ? 'aa' : 'eoa'}
    webBrowser={WebBrowser}
    storage={Storage}
    config={config}>
    {/* ... */}
  </Web3AuthProvider>
)

```

Where `getWeb3AuthConfig(useAA)` returns `accountAbstractionConfig: useAA ? aaConfig : null`.

## Use the smart account

With smart accounts enabled, `connection.ethereumProvider` sends transactions as user operations from the smart account. Use it with viem, ethers, or [Wagmi](/embedded-wallets/sdk/react-native/ethereum-hooks/).

### Get the smart account address

The first address is the smart account, and the second is the EOA that signs for it:

```tsx
import { useWeb3Auth } from '@web3auth/react-native-sdk'
import { createWalletClient, custom } from 'viem'

const { connection } = useWeb3Auth()
const walletClient = createWalletClient({ transport: custom(connection!.ethereumProvider!) })

const [smartAccountAddress, eoaAddress] = await walletClient.getAddresses()

```

### Send a transaction

Provide only `to`, `value`, and `data`. The SDK builds the user operation, sets gas fees through the bundler, and submits it. The first transaction also deploys the smart account.

```tsx
import { parseEther } from 'viem'

const hash = await walletClient.sendTransaction({
  account: smartAccountAddress,
  to: '<DESTINATION_ADDRESS>',
  value: parseEther('0.001'),
  chain: null,
})

```
