# Privy signer

[Privy](https://www.privy.io/) is an embedded wallet provider that simplifies user onboarding for dApps, enabling seamless authentication and key management.

## Create the Privy provider

Follow Privy’s [quickstart guide](https://docs.privy.io/guide/quickstart), to set up the Privy provider in your app.

```tsx
import { PrivyProvider } from '@privy-io/react-auth';
import {WagmiProvider} from '@privy-io/wagmi'; 
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
import {createConfig} from '@privy-io/wagmi'; 

import { http } from "viem";
import { arbitrumSepolia } from "viem/chains";


const queryClient = new QueryClient(); 
 
const config = createConfig({ 
  chains: [arbitrumSepolia], 
  transports: { 
    [arbitrumSepolia.id]: http(), 
  }, 
}); 

<PrivyProvider
  appId={"<Privy-App-Id>"}
  config={{
    embeddedWallets: {
      createOnLogin: "all-users",
    },
  }}
>
   <QueryClientProvider client={queryClient}>
    <WagmiProvider config={config}>
        {children}
     </WagmiProvider>
  </QueryClientProvider>
</PrivyProvider>;
 
```

## Integration

In your app, set Privy's embedded wallet as the active wallet for wagmi by using the **useWallets** react hook (after[ Privy login](https://docs.privy.io/guide/react/authentication/login/)).

```typescript
import { useWallets } from "@privy-io/react-auth";


const { wallets } = useWallets();
const embeddedWallet = wallets.find(
  (wallet) => wallet.walletClientType === "privy"
);

```

You will have access to a Privy signer object as shown below that you can pass as an owner to `createSafeSmartAccount`:

```typescript
import {
    providerToSmartAccountSigner
} from "@cometh/connect-core-sdk";


if (!embeddedWallet) throw new Error("User does not have an embedded wallet");

const privyProvider = await embeddedWallet!.getEthereumProvider()
const signer = await providerToSmartAccountSigner(privyProvider);

```
