For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Integrate Embedded Wallets with the Solana Blockchain in JavaScript

While using the Embedded Wallets Web SDK, read connection.solanaWallet from web3auth.connection after sign-in. Use this page for VanillaJS, Angular, and other frameworks. For React and Vue, prefer the Solana hooks and composables instead.

Chain details for Solana

  • Chain Namespace: SOLANA
  • Chain ID: 0x1
  • Public RPC URL: https://api.mainnet-beta.solana.com (avoid public RPC in production; prefer managed services)
  • Display Name: Solana Mainnet
  • Block Explorer Link: https://explorer.solana.com
  • Ticker: SOL
  • Ticker Name: Solana
  • Logo: https://images.toruswallet.io/solana.svg

For VanillaJS, Angular and other frameworks

Installation

Install @solana/kit and @solana-program/system to build Solana transactions with the Embedded Wallets Web SDK.

npm install --save @solana/kit @solana-program/system

Getting the Solana wallet

After sign-in, access the Solana wallet from the connection object:

// Initialize for PnP Web SDK
await web3auth.init()

// Trigger the login
await web3auth.connect()

const solanaWallet = web3auth.connection?.solanaWallet ?? null
Review required

Vanilla JavaScript Solana flows with @solana/kit should be validated against your target SDK version before production use. For reference implementations, see the React Solana quick start example.

Get account and balance

Use solanaWallet with @solana/kit RPC helpers. The exact RPC surface depends on your chain configuration in the Embedded Wallets dashboard.

import { address } from '@solana/kit'

const solanaWallet = web3auth.connection?.solanaWallet ?? null
if (!solanaWallet) return

// Request accounts from the connected wallet
const accounts = await solanaWallet.features['standard:connect']?.connect()

For React and Vue apps, prefer useSolanaWallet() from @web3auth/modal/react/solana or @web3auth/modal/vue/solana, which exposes accounts and rpc directly.

Fetch user's private key

solana_privateKey is used to fetch the private key of the signed-in user. It is only available for in-app adapters such as auth.

const provider = web3auth.connection?.ethereumProvider ?? null
const privateKey = await provider?.request({
method: 'solana_privateKey',
})