@privy-io/js-sdk-core
Usage
Auth
const privy = new Privy({appId: '<your-app-id-here>'});
await privy.auth.sms.sendCode('+1 555 555 5555');
const {user} = await privy.auth.sms.loginWithCode('+1 555 555 5555', '123123');
Embedded Wallets
import {createWalletClient, custom} from 'viem';
const privy = new Privy({appId: '<your-app-id-here>'});
await privy.auth.sms.sendCode('+1 555 555 5555');
const {user} = await privy.auth.sms.loginWithCode('+1 555 555 5555', '123123');
const wallet = await privy.embeddedWallet.create();
const accounts = await wallet.request({method: 'eth_requestAccounts'});
const response = await wallet.request({
method: 'eth_sendTransaction',
params: [
{
from: accounts[0],
to: '0x0000000000000000000000000000000000000000',
value: '1',
},
],
});
const viemWalletClient = createWalletClient({
chain: mainnet,
transport: custom(wallet),
});
await viemWalletClient.signMessage({
message: 'Hello from Privy!',
account: wallet.address,
});