Socket
Socket
Sign inDemoInstall

@privy-io/js-sdk-core

Package Overview
Dependencies
57
Maintainers
7
Versions
519
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @privy-io/js-sdk-core

Vanilla JS client for the Privy Auth API


Version published
Maintainers
7
Install size
27.4 MB
Created

Readme

Source

@privy-io/js-sdk-core

🔧 The Privy JS SDK is a low-level library and not intended for general consumption.

Before building, please reach out to the Privy team to discuss your project and which Privy SDK options may be better suited to it.

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

// Or use the embedded wallet with viem
import {createWalletClient, custom} from 'viem';

// Initialize the client
const privy = new Privy({appId: '<your-app-id-here>'});

// Log in
await privy.auth.sms.sendCode('+1 555 555 5555');
const {user} = await privy.auth.sms.loginWithCode('+1 555 555 5555', '123123');

// Create an embedded wallet
const wallet = await privy.embeddedWallet.create();

// Use the embedded wallet
const accounts = await wallet.request({method: 'eth_requestAccounts'});
const response = await wallet.request({
  method: 'eth_sendTransaction',
  params: [
    {
      from: accounts[0],
      to: '0x0000000000000000000000000000000000000000',
      value: '1',
    },
  ],
});

// create a viem client from the privy embedded wallet
const viemWalletClient = createWalletClient({
  chain: mainnet,
  transport: custom(wallet),
});

// use viem to sign a message
await viemWalletClient.signMessage({
  message: 'Hello from Privy!!',
  account: wallet.address,
});

Keywords

FAQs

Last updated on 30 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc