# @web3auth/solana-provider

Latest version **9.7.0** (published 2025-03-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @web3auth/solana-provider
pnpm add @web3auth/solana-provider
yarn add @web3auth/solana-provider
bun add @web3auth/solana-provider
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 9.7.0 |
| Published | 2025-03-05 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.x |
| Dependencies | 8 |
| Unpacked size | 512.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 491 |
| Author | Torus Labs |
| Maintainers | chaitanyapotti, archit_web3, himanshunpm009 |

## Links

- npm: https://www.npmjs.com/package/@web3auth/solana-provider
- Repository: https://github.com/Web3Auth/Web3Auth
- Homepage: https://github.com/Web3Auth/Web3Auth#readme
- Issues: https://github.com/Web3Auth/Web3Auth/issues
- npm.io page: https://npm.io/package/@web3auth/solana-provider

## Dependencies (8)

- [bs58](https://npm.io/package/bs58.md) ^5.0.0
- [bn.js](https://npm.io/package/bn.js.md) ^5.2.1
- [@web3auth/auth](https://npm.io/package/@web3auth/auth.md) ^9.6.4
- [@web3auth/base](https://npm.io/package/@web3auth/base.md) ^9.7.0
- [json-rpc-random-id](https://npm.io/package/json-rpc-random-id.md) ^1.0.1
- [@toruslabs/tweetnacl-js](https://npm.io/package/@toruslabs/tweetnacl-js.md) ^1.0.4
- [@web3auth/base-provider](https://npm.io/package/@web3auth/base-provider.md) ^9.7.0
- [@toruslabs/base-controllers](https://npm.io/package/@toruslabs/base-controllers.md) ^7.2.1

## Recent versions

- 9.7.0 (latest) — 2025-03-05
- 9.5.0-alpha.1 (next) — 2024-12-06
- 9.6.0 — 2025-02-14
- 9.5.4 — 2025-02-06
- 9.5.3 — 2025-01-20
- 9.5.2 — 2025-01-08
- 9.5.1 — 2024-12-19
- 9.5.0 — 2024-12-16
- 9.4.5 — 2024-11-29
- 9.4.4 — 2024-11-23
- 9.4.2 — 2024-11-22
- 9.4.0 — 2024-11-08
- 9.3.0 — 2024-10-22
- 9.2.3 — 2024-10-14
- 9.2.2 — 2024-10-11
- … 138 more at https://npm.io/package/@web3auth/solana-provider/versions

## README

# Web3Auth Solana Provider

[![npm version](https://img.shields.io/npm/v/@web3auth/solana-provider?label=%22%22)](https://www.npmjs.com/package/@web3auth/solana-provider/v/latest)
[![minzip](https://img.shields.io/bundlephobia/minzip/@web3auth/solana-provider?label=%22%22)](https://bundlephobia.com/result?p=@web3auth/solana-provider@latest)

> Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.

Web3Auth Solana Provider can be used to interact with wallet or connected Solana chain using RPC calls. This is a Solana chain compatible JRPC provider.

## 📖 Documentation

Read more about Web3Auth Solana Provider in the [official Web3Auth Documentation](https://web3auth.io/docs/sdk/web/providers/solana#getting-a-provider-from-any-secp256k1-private-key).

## 💡 Features

- Plug and Play, OAuth based Web3 Authentication Service
- Fully decentralized, non-custodial key infrastructure
- End to end Whitelabelable solution
- Threshold Cryptography based Key Reconstruction
- Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
- Support for WebAuthn & Passwordless Login
- Support for connecting to multiple wallets
- DApp Active Session Management

...and a lot more

## 🔗 Installation

```shell
npm install --save @web3auth/solana-provider
```

## 🩹 Example

### `SolanaPrivateKeyProvider`

```ts
import { SolanaPrivateKeyProvider } from "@web3auth/solana-provider";

const solanaPrivateProvider = await SolanaPrivateKeyProvider.getProviderInstance({
  chainConfig: {
    rpcTarget: "https://ssc-dao.genesysgo.net",
    chainId: "0x1", // hex chain id
    displayName: "solana",
    ticker: "SOL",
    tickerName: "Solana",
  },
  privKey: "user's private key",
});
```

### `SolanaWallet`

`SolanaWallet` can be used with two types of providers:

1. `web3auth.provider` that you get after logging in with Web3Auth.
2. `solanaPrivateProvider.provider` that you get after passing user's private key to `SolanaPrivateKeyProvider`.

`web3auth.provider`

```ts
import { SolanaWallet } from "@web3auth/solana-provider";

const solanaWallet = new SolanaWallet(web3auth.provider);
const msg = Buffer.from("Signing Message", "utf8");
const result = await solanaWallet.signMessage(msg);
return result;
```

`solanaPrivateProvider.provider`

```ts
import { SolanaWallet } from "@web3auth/solana-provider";

const solanaWallet = new SolanaWallet(solanaPrivateProvider.provider);
const msg = Buffer.from("Signing Message", "utf8");
const result = await solanaWallet.signMessage(msg);
return result.toString();
```

### General Example

```ts
import { SolanaPrivateKeyProvider, SolanaWallet } from "@web3auth/solana-provider";
import type { SafeEventEmitterProvider } from "@web3auth/base";

const signSolanaMessage = async (provider: SafeEventEmitterProvider): Promise<string> => {
  const solanaWallet = new SolanaWallet(provider as any);
  const msg = Buffer.from("Signing Message", "utf8");
  const result = await solanaWallet.signMessage(msg);
  return result.toString();
};

(async () => {
  // Assuming you're logged in with Web3Auth.
  const privateKey = await web3auth.provider.request({
    method: "solanaPrivateKey",
  });
  const solanaPrivateProvider = await SolanaPrivateKeyProvider.getProviderInstance({
    chainConfig: {
      rpcTarget: "https://ssc-dao.genesysgo.net",
      chainId: "0x1", // hex chain id
      displayName: "solana",
      ticker: "SOL",
      tickerName: "Solana",
    },
    privKey: privateKey,
  });
  const signedMessage = await signSolanaMessage(solanaPrivateProvider.provider);
})();
```

Check out the examples for your preferred blockchain and platform on our [examples page](https://web3auth.io/docs/examples).

## 🌐 Demo

Checkout the [Web3Auth Demo](https://demo.web3auth.io) to see how Web3Auth can be used in your application.

## 💬 Troubleshooting and Support

- Have a look at our [Community Portal](https://community.web3auth.io/) to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible.
- Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions.
- For Priority Support, please have a look at our [Pricing Page](https://web3auth.io/pricing.html) for the plan that suits your needs.

---
_Source: https://npm.io/package/@web3auth/solana-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
