solana_wallet_provider 0.1.9 copy "solana_wallet_provider: ^0.1.9" to clipboard
solana_wallet_provider: ^0.1.9 copied to clipboard

Provider widget for solana_web3 and solana_wallet_adapter packages.

Provides access to solana_web3 and solana_wallet_adapter in the widget tree and creates UI wrappers around Mobile Wallet Adapter Specification method calls.


Sign and Send Transaction

Solana Wallet Provider Example App


API #

  • connect - authorizes the application with an available wallet or presents a list of download options.
  • disconnect - presents the authorized accounts and a disconnect button to deauthorize the application.
  • signTransactions - signs transactions with the authorized account.
  • signAndSendTransactions - signs transactions with the authorized account then broadcasts them to the network.
  • signMessages - signs messages with the authorized account.

Convenience Widget #

  • SolanaWalletButton - A button widget that toggles authorization of the application with a wallet.

Dapp Identity Verification #

Wallet endpoints will use your AppIdentity information to decide whether to extend trust to your dapp.

AppIdentity(
    uri: Uri.parse('https://<YOUR_DOMAIN>'),
    icon: Uri.parse('favicon.png'),
    name: '<APP_NAME>'
)

Android Setup #

  1. Get your application id.
// FILE: /android/app/build.gradle
defaultConfig {
    applicationId "<APPLICATION_ID>"
}
  1. Generate your application's sha256 fingerprint.
$ cd android
$ ./gradlew app:signingReport

// Output:
//  ...
//  SHA-256: <SHA256_FINGERPRINT>
//  ...
  1. Host a Digital Asset Links file with the following contents:
// GET: https:://<YOUR_DOMAIN>/.well-known/assetlinks.json
[{
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": { 
        "namespace": "android_app", 
        "package_name": "<APPLICATION_ID>",
        "sha256_cert_fingerprints": ["<SHA256_FINGERPRINT>"]
    }
}]

Theme #

Add SolanaWalletThemeExtension as a ThemeData extension to customize the provider's appearance.

ThemeData(
    extensions: const [
        SolanaWalletThemeExtension(
            cardTheme: SolanaWalletCardTheme(
                color: Colors.indigo,
            ),
        ),
    ],
);

Example: Connect #

Uses the provider to authorize the application with a Solana wallet.

import 'package:flutter/material.dart';
import 'package:solana_wallet_provider/solana_wallet_provider.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});
  @override
  Widget build(final BuildContext context) {
    // 1. Wrap application with SolanaWalletProvider.
    return SolanaWalletProvider.create(                           
      identity: const AppIdentity(),
      child: MaterialApp(
        home: Scaffold(
          body: FutureBuilder(
            // 2. Initialize SolanaWalletProvider before use.
            future: SolanaWalletProvider.initialize(),            
            builder: ((context, snapshot) {
              // 3. Access SolanaWalletProvider.
              final provider = SolanaWalletProvider.of(context);
              return TextButton(
                onPressed: () => provider.connect(context),
                child: const Center(
                  child: Text('Example App'),
                ),
              );
            }),
          ),
        ),
      ),
    );
  }
}

Bugs #

Report a bug by opening an issue.

Feature Requests #

Request a feature by raising a ticket.