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
- Yarn
- pnpm
npm install --save @web3auth/default-solana-adapter
yarn add @web3auth/default-solana-adapter
pnpm add @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
- Table
- Interface
Parameter | Description |
---|---|
options | Accepts IWeb3AuthCoreOptions used to initialize the Web3Auth SDK. |
export declare const getDefaultExternalAdapters: (params: {
options: IWeb3AuthCoreOptions;
}) => Promise<IAdapter<unknown>[]>;
export declare const getInjectedAdapters: (params: {
options: IWeb3AuthCoreOptions;
}) => Promise<IAdapter<unknown>[]>;
Usage
- getDefaultExternalAdapters
- getInjectedAdapters
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);
});
import { getInjectedAdapters } 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 getInjectedAdapters({ options: web3AuthOptions });
adapters.forEach((adapter) => {
web3auth.configureAdapter(adapter);
});