Plaid logo
Docs
ALL DOCS

Wallet Onboard (beta)

  • Introduction to Wallet Onboard
  • Add Wallet Onboard to your app
  • Using a Provider
  • Optimize your wallet
Plaid logo
Docs
Plaid.com
Get API keys
Open nav

Solana Provider

Request data and signatures from Solana wallets

Solana Providers are a Wallet Standard compliant Provider object. Used by the Solana JavaScript SDK, the Provider object contains details of connected wallets and exposes methods for signing and sending messages and transactions. The most frequently supported methods include:

  • provider.signMessage(message) - Sign a message with the connected wallet
  • provider.signTransaction(transaction) - Sign a transaction with the connected wallet
  • provider.sendTransaction(transaction, connection, options) - Send a transaction to a specified Solana connection
  • provider.on(event, callback) - Subscribe to events like account or connection changes
  • provider.removeListener(event, callback) - Remove subscriptions added by provider.on

Here are some examples of using the provider:

Copy
1function async signData() {
2 const dataToSign = 'Hello World';
3 const inputArray = new TextEncoder().encode(dataToSign);
4
5 // plaidProvider returned earlier from Wallet Onboard
6 const result = await plaidProvider.signMessage(inputArray);
7 return result;
8}
Copy
1import { SystemProgram, Transaction, Connection } from '@solana/web3.js';
2
3function async sendTransaction() {
4 const publicKey = plaidProvider.publicKey;
5 const toPubKey = destination; // destination public key
6
7 const transaction = new Transaction().add(
8 SystemProgram.transfer({
9 fromPubkey: publicKey,
10 lamports: 1000000,
11 toPubkey,
12 }),
13 );
14
15 const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
16 const {
17 context: { slot: minContextSlot },
18 value: { blockhash, lastValidBlockHeight },
19 } = await connection.getLatestBlockhashAndContext();
20
21 const signature = await plaidProvider.sendTransaction(transaction, connection, { minContextSlot });
22 await connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature });
23}

For more documentation on the available methods, see the Solana docs.

Was this helpful?
Developer community
GitHub
GitHub
Stack Overflow
Stack Overflow
YouTube
YouTube
Twitter
Twitter
Discord
Discord