Skip to main content

Default Solana Adapter

@web3auth/default-solana-adapter

The default Solana adapter enables seamless detection of injected Solana wallets, allowing interaction with just a single line of code.

Basic Details

Adapter Name: default-solana-adapter

Package Name: @web3auth/default-solana-adapter

authMode: DAPP

chainNamespace: SOLANA

Default: NO

Installation

npm install --save @web3auth/default-solana-adapter

Injected Wallets

To automatically fetch all the available Solana wallets in browser context, you can use the getInjectedAdapters, or getDefaultExternalAdapters function. This function uses Wallet Standard for Solana so all available wallets in the browser will automatically be detected.

Parameters

ParameterDescription
optionsAccepts IWeb3AuthCoreOptions used to initialize the Web3Auth SDK.

Usage

import { getDefaultExternalAdapters } from "@web3auth/default-solana-adapter";
import { SolanaPrivateKeyProvider } from "@web3auth/solana-provider";

const chainConfig = {
chainId: "0x2",
chainNamespace: CHAIN_NAMESPACES.SOLANA,
rpcTarget: "https://api.devnet.solana.com",
tickerName: "SOLANA",
ticker: "SOL",
decimals: 9,
blockExplorerUrl: "https://explorer.solana.com/?cluster=devnet",
logo: "https://images.toruswallet.io/sol.svg",
};

const privateKeyProvider = new SolanaPrivateKeyProvider({ config: { chainConfig } });

const web3AuthOptions: Web3AuthOptions = {
clientId,
chainConfig,
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
privateKeyProvider: privateKeyProvider,
};

const adapters = await getDefaultExternalAdapters({ options: web3AuthOptions });

adapters.forEach((adapter) => {
web3auth.configureAdapter(adapter);
});