Solflare Wallet
  • ☀️Introduction
    • The Power of Self-Custody
    • Benefits of Non-Custodial Wallets
    • Digital Wallet Best Practices
    • Bigger Picture
  • Onboarding
    • 📞Mobile
      • Generate a New Wallet
      • Connect a Ledger Wallet
      • Import any Solana Wallet
    • 🖥️Web App & Extension
      • Generate a New Wallet
      • Import Your Ledger Device
      • Import Your Keystone Device
      • Import any Solana Wallet
    • 🚶Next Steps
  • Integrations
    • ⛓️Integrate Solflare
      • MetaMask
      • Using the Solana Wallet Adapter
      • Solflare Wallet SDK
    • 🎭Profile Picture Protocol
      • Get a Wallet's Profile Picture
      • Set NFT as Profile Picture
      • Remove a Profile Picture
    • ⚡Solflare Notifications
      • Sending Notifications
      • User's Perspective
        • Notification Center
        • Receiving Notifications
        • Subscription Management
      • API Endpoints
        • Broadcast Endpoint
        • Unicast Endpoint
        • List Casts Endpoint
        • View Cast Endpoint
        • Check Public Key Subscription Status for Domain
    • 🖼️NFT Standard
      • URI JSON Schema
      • CDN hosted files
      • Collections
      • Additional Attributes Specification
      • Order of JSON Fields
    • 🔗Deeplinks
      • Provider Methods
        • Connect
        • Disconnect
        • SignAndSendTransaction
        • SignAllTransactions
        • SignTransaction
        • SignMessage
      • Other Methods
        • Browse
      • Handling Sessions
      • Specifying Redirects
      • Encryption
      • Limitations
Powered by GitBook
On this page

Was this helpful?

  1. Integrations
  2. Integrate Solflare

Solflare Wallet SDK

PreviousUsing the Solana Wallet AdapterNextProfile Picture Protocol

Last updated 1 year ago

Was this helpful?

If your dApp does not use the , 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', () => {
    console.log('disconnected');
});

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([
    transaction1,
    transaction2
]);

Sign a test message:

const message = 'To verify your wallet on https://example.com, with this message';

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

const signature: Uint8Array = await wallet.signMessage(messageBytes, 'utf8');
⛓️
Solana Wallet Adapter