solana_wallet_adapter

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

solana wallet adapter

Dart implementation of Solana's Mobile Wallet Adapter Specification protocol. The protocol exposes functionalities of Android and iOS wallet apps (e.g. Solflare) to dapps.



Screenshot of solana_wallet_provider

Non-privileged Methods #
Non-privileged methods do not require the current session to be in an authorized state to invoke them.

authorize
deauthorize
reauthorize
getCapabilities


Privileged Methods #
Privileged methods require the current session to be in an authorized state to invoke them. For details on how a session enters and exits an authorized state, see the non-privileged methods.

signTransactions
signAndSendTransactions
signMessages


Setup #
Connect your wallet application (e.g. Phantom) and SolanaWalletAdapter to the same network. The wallet application may not support localhost.

Example: Authorize #
import 'package:flutter/material.dart';
import 'package:solana_wallet_adapter/solana_wallet_adapter.dart';

void main() {
runApp(const MaterialApp(
home: Scaffold(
body: Center(
child: AuthorizeButton(),
),
),
));
}

// 1. Create instance of [SolanaWalletAdapter].
final adapter = SolanaWalletAdapter(
const AppIdentity(),
// NOTE: CONNECT THE WALLET APPLICATION
// TO THE SAME NETWORK.
cluster: Cluster.devnet,
);

class AuthorizeButton extends StatefulWidget {
const AuthorizeButton({super.key});
@override
State<AuthorizeButton> createState() => _AuthorizeButtonState();
}

class _AuthorizeButtonState extends State<AuthorizeButton> {
Object? _output;
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {
// 2. Authorize application with wallet.
adapter.authorize()
.then((result) => setState(() => _output = result.toJson()))
.catchError((error) => setState(() => _output = error));
},
child: const Text('Authorize'),
),
if (_output != null)
Text(_output.toString()),
],
);
}
}
copied to clipboard

Bugs #
Report a bug by opening an issue.
Feature Requests #
Request a feature by raising a ticket.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.