Skip to main content

Custom UI

ZeroDev provides a number of "social connectors" for creating smart wallets with social accounts. Under the hood, we use Web3Auth to generate a private key from a social account, then set the private key as the owner of the smart wallet. From the perspective of the end user, they are just signing in with a social account, and getting a smart wallet at the end.

Social connectors are available in Wagmi and Ethers.

Wagmi

Install our Wagmi package:

npm i @zerodevapp/wagmi

Then initialize a connector by passing in a ZeroDev project ID, as follows:

import { 
GoogleSocialWalletConnector,
FacebookSocialWalletConnector,
GithubSocialWalletConnector,
DiscordSocialWalletConnector,
TwitchSocialWalletConnector,
TwitterSocialWalletConnector,
} from '@zerodevapp/wagmi'

const connector = new GoogleSocialWalletConnector({options: {
projectId: <your-project-id>,
}})

Example:

Full Code (Editable)
Result
Loading...

Ethers

Install the following package:

npm i @zerodevapp/web3auth

Then import the social wallets and use them with getZeroDevSigner from the SDK:

import { getZeroDevSigner, getRPCProviderOwner } from '@zerodevapp/sdk'
import { ZeroDevWeb3Auth, ZeroDevWeb3AuthWithModal } from '@zerodevapp/web3auth';

let signer: ZeroDevSigner

const zeroDevWeb3AuthNoModal = new ZeroDevWeb3Auth(['<project-id>'])
zeroDevWeb3AuthNoModal.init({onConnect: async () => {
signer = await getZeroDevSigner({
projectId: "<project id>",
owner: await getRPCProviderOwner(ZeroDevWeb3Auth.provider),
})
}})
// 'google' | 'facebook' | 'twitter' | 'discord' | 'github' | 'twitch'
ZeroDevWeb3Auth.connect('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...