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
- Mainnet
- Testnet
- Devnet
- 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
- Chain Namespace: SOLANA
- Chain ID: 0x2
- Public RPC URL:
https://api.testnet.solana.com(avoid public RPC in production; prefer managed services) - Display Name: Solana Testnet
- Block Explorer Link:
https://explorer.solana.com - Ticker: SOL
- Ticker Name: Solana
- Logo: https://images.toruswallet.io/solana.svg
- Chain Namespace: SOLANA
- Chain ID: 0x3
- Public RPC URL:
https://api.devnet.solana.com(avoid public RPC in production; prefer managed services) - Display Name: Solana Devnet
- Block Explorer Link:
https://explorer.solana.com?cluster=devnet - 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
- Yarn
- pnpm
- Bun
npm install --save @solana/kit @solana-program/system
yarn add @solana/kit @solana-program/system
pnpm add @solana/kit @solana-program/system
bun add @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
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',
})