Solflare Wallet SDK

If your dApp does not use the Solana Wallet Adapter, you can integrate Solflare directly using the Solflare Wallet SDK.

First, install the package:

npm install @solflare-wallet/sdk@latest

Initialize the SDK:

import Solflare from '@solflare-wallet/sdk';

const wallet = new Solflare();

wallet.on('connect', () => {
    console.log('connected', wallet.publicKey.toString());
wallet.on('disconnect', () => {

Connect to the wallet - this will trigger either the extension, web or mobile connection. The returned promise will resolve when the user accepted or rejected the connection.

await wallet.connect();

Send a Solana transaction:

const transaction = new Transaction();
// add instructions

const txSignature: string = await wallet.signAndSendTransaction(transaction);

If you only want to sign one or multiple transactions:

const signedTransaction: Transaction = await wallet.signTransaction(transaction);

const signedTransactions: Transaction[] = await wallet.signAllTransactions([

Sign a test message:

const message = 'To verify your wallet on, with this message';

const messageBytes = new TextEncoder().encode(message);

const signature: Uint8Array = await wallet.signMessage(messageBytes, 'utf8');

Last updated