Create AA Wallets with Socials/Emails
With ZeroDev, you can create AA wallets for users using their social accounts or emails. There are two ways to do so:
Use Privy, a popular onboarding solution that natively integrates with ZeroDev.
Use our "social connectors" which are compatible with Wagmi/Ethers and wallet kits like RainbowKit/ConnectKit.
Read on to learn more about our social connectors.
API
Social connectors are available in Wagmi and Ethers.
Wagmi
Install our Wagmi package:
npm i @zerodev/wagmi
Then initialize a connector by passing in a ZeroDev project ID, as follows:
import {
GoogleSocialWalletConnector,
FacebookSocialWalletConnector,
GithubSocialWalletConnector,
DiscordSocialWalletConnector,
TwitchSocialWalletConnector,
TwitterSocialWalletConnector,
} from '@zerodev/wagmi'
const connector = new GoogleSocialWalletConnector({options: {
projectId: <your-project-id>,
}})
Example:
Full Code (Editable)
Ethers
Install the following package:
npm i @zerodev/web3auth
Then import the social wallets and use them with ECDSAProvider
from the SDK:
import { ECDSAProvider, getRPCProviderOwner } from '@zerodev/sdk'
import { ZeroDevWeb3Auth, ZeroDevWeb3AuthWithModal } from '@zerodev/web3auth';
let ecdsaProvider: ECDSAProvider
const zeroDevWeb3AuthNoModal = new ZeroDevWeb3Auth(['<project-id>'])
zeroDevWeb3AuthNoModal.initialize({onConnect: async () => {
ecdsaProvider = await ECDSAProvider.init({
projectId: "<project id>",
owner: await getRPCProviderOwner(ZeroDevWeb3Auth.provider),
})
}})
// 'google' | 'facebook' | 'twitter' | 'discord' | 'github' | 'twitch'
zeroDevWeb3AuthNoModal.login('google')
You can pick and choose the social login methods you'd like to use, or use ZeroDevWeb3Auth
which shows a meta login modal with all login methods. Here's an example:
Full Code (Editable)
Connect Wallet Kits
There are many "connect-wallet kits" out there such as RainbowKit and ConnectKit. For your convenience, we have built integrations with the most popular kits.
RainbowKit
You can easily add social logins to RainbowKit with our helper wallets. Here is a complete example.
To import the helper wallets:
import {
googleWallet,
facebookWallet,
githubWallet,
discordWallet,
twitchWallet,
twitterWallet,
} from '@zerodev/wagmi/rainbowkit'
These can be used with RainbowKit's connectorsForWallets
function to customize the wallet list:
import { connectorsForWallets } from '@rainbow-me/rainbowkit'
ConnectKit
Due to the way ConnectKit is structured, we need a hack to add social logins. Start by adding this code to your app's initialization flow:
import { supportedSocialConnectors } from '@zerodev/wagmi/connectkit'
import { supportedConnectors } from "connectkit";
supportedConnectors.push(...supportedSocialConnectors)
Then you can use ConnectKit with our social connectors:
import {
SocialWalletConnector,
GoogleSocialWalletConnector,
FacebookSocialWalletConnector,
GithubSocialWalletConnector,
DiscordSocialWalletConnector,
TwitchSocialWalletConnector,
TwitterSocialWalletConnector,
} from '@zerodev/wagmi'
import { createConfig } from "wagmi"
import { getDefaultConfig } from "connectkit"
Web3Modal
Configure the Wagmi client with ZeroDev's social connectors, and it will seamlessly work with Web3Modal.
import { web3ModalConfig } from '@zerodev/wagmi/web3modal'
import {
SocialWalletConnector,
GoogleSocialWalletConnector,
FacebookSocialWalletConnector,
GithubSocialWalletConnector,
DiscordSocialWalletConnector,
TwitchSocialWalletConnector,
TwitterSocialWalletConnector,
} from '@zerodev/wagmi'
import {
EthereumClient,
modalConnectors,
w3mProvider,
w3mConnectors,
} from "@web3modal/ethereum";
import { Web3Modal, Web3Button } from "@web3modal/react";