Provides access to solana_web3 and solana_wallet_adapter in the widget tree and creates UI wrappers around Mobile Wallet Adapter Specification method calls.
Solana Wallet Provider Example App
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.
SolanaWalletButton
- A button widget that toggles authorization of the application with a wallet.
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>'
)
- Get your application id.
// FILE: /android/app/build.gradle
defaultConfig {
applicationId "<APPLICATION_ID>"
}
- Generate your application's sha256 fingerprint.
$ cd android
$ ./gradlew app:signingReport
// Output:
// ...
// SHA-256: <SHA256_FINGERPRINT>
// ...
- 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>"]
}
}]
Add SolanaWalletThemeExtension
as a ThemeData
extension to customize the provider's appearance.
ThemeData(
extensions: const [
SolanaWalletThemeExtension(
cardTheme: SolanaWalletCardTheme(
color: Colors.indigo,
),
),
],
);
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'),
),
);
}),
),
),
),
);
}
}
Report a bug by opening an issue.
Request a feature by raising a ticket.