This quickstart guide will demonstrate how to authenticate a user with a one time password as an
example, but Privy supports many authentication methods. Explore our Authentication
docs to learn about other methods such as socials, passkeys, and
external wallets to authenticate users in your app.
To authenticate a user via their email address, use the React Native SDK’s useLoginWithEmail hook.
import {useLoginWithEmail} from '@privy-io/expo';...const {sendCode, loginWithCode} = useLoginWithEmail();
Ensure that this hook is mounted in a component that is wrapped by the PrivyProvider.
You can use the returned methods sendCode and loginWithCode to authenticate your user per the instructions below.
Your app can configure Privy to automatically create wallets for your users as part of their login flow. The embedded wallet will be generated and linked to the user object upon authentication.
3. Send and sign transactions using the embedded wallet
To request signatures and transactions from a wallet, you must first get an EIP1193 provider for the wallet.
import {useEmbeddedEthereumWallet} from '@privy-io/expo';// Get an EIP-1193 Providerconst {wallets} = useEmbeddedEthereumWallet();const provider = await wallets[0].getProvider();
Once you have the embedded wallet’s EIP-1193 provider, you can use the provider’s request method to send JSON-RPC requests that request signatures and transactions from the wallet!
The request method accepts an object with the fields:
method (required): the name of the JSON-RPC method as a string (e.g. personal_sign or eth_sendTransaction)
params (optional): an array of arguments for the JSON-RPC method specified by method
// Get address// Get an EIP-1193 Providerconst provider = await wallet.getProvider();const accounts = await provider.request({ method: 'eth_requestAccounts'});// Send transaction (will be signed and populated)const response = await provider.request({ method: 'eth_sendTransaction', params: [ { from: accounts[0], to: '0x0000000000000000000000000000000000000000', value: '1' } ]});
import {useEmbeddedEthereumWallet} from '@privy-io/expo';// Get an EIP-1193 Providerconst {wallets} = useEmbeddedEthereumWallet();const provider = await wallets[0].getProvider();
Once you have the embedded wallet’s EIP-1193 provider, you can use the provider’s request method to send JSON-RPC requests that request signatures and transactions from the wallet!
The request method accepts an object with the fields:
method (required): the name of the JSON-RPC method as a string (e.g. personal_sign or eth_sendTransaction)
params (optional): an array of arguments for the JSON-RPC method specified by method
// Get address// Get an EIP-1193 Providerconst provider = await wallet.getProvider();const accounts = await provider.request({ method: 'eth_requestAccounts'});// Send transaction (will be signed and populated)const response = await provider.request({ method: 'eth_sendTransaction', params: [ { from: accounts[0], to: '0x0000000000000000000000000000000000000000', value: '1' } ]});
import {useEmbeddedSolanaWallet} from '@privy-io/expo';// get a Solana providerconst {wallets} = useEmbeddedSolanaWallet();const provider = await wallets[0].getProvider();
Once you have the embedded wallet’s Solana provider, you can use the provider’s methods to interact with the Solana blockchain.