Skip to main content

Create AA Wallets with Socials/Emails

Demo


Introduction

With ZeroDev, you can create AA wallets for users using their social accounts or emails. There are two ways to do so:

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)
Result
Loading...

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)
Result
Loading...

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'
Live Editor
Result
Loading...

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"
Live Editor
Result
Loading...

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";
Live Editor
Result
Loading...