solana_kit_mobile_wallet_adapter 0.2.0 copy "solana_kit_mobile_wallet_adapter: ^0.2.0" to clipboard
solana_kit_mobile_wallet_adapter: ^0.2.0 copied to clipboard

Flutter plugin for the Solana Mobile Wallet Adapter protocol. Enables dApps to communicate with wallet apps for transaction signing on Android. iOS compiles but is a no-op.

solana_kit_mobile_wallet_adapter #

pub package docs CI coverage

Flutter plugin for the Solana Mobile Wallet Adapter (MWA) protocol. Enables dApps and wallet apps to communicate for transaction signing on Android.

Android-only. MWA is not supported on iOS. This plugin compiles and runs on iOS without crashing (no-op), so mixed-platform Flutter apps work without conditional compilation.

Features #

dApp side (client) #

  • transact() - One-call session lifecycle: launch wallet, handshake, execute callback, clean up
  • LocalAssociationScenario - Full control over local WebSocket sessions with retry logic
  • RemoteAssociationScenario - Remote sessions via WebSocket reflector (cross-device)
  • KitMobileWallet - Typed API working with base64 payloads and Solana Kit types
  • Platform check - isMwaSupported() / assertMwaSupported()

Wallet side (server) #

  • WalletScenario - Manages incoming dApp connections via native Android bridge
  • WalletScenarioCallbacks - Interface for handling authorize, sign, and deauthorize requests
  • Typed request/response - AuthorizeDappRequest, SignTransactionsRequest, etc. with completeWith* methods
  • MobileWalletAdapterConfig - Wallet capabilities (max payloads, features, transaction versions)

Installation #

flutter pub add solana_kit_mobile_wallet_adapter

If you're working inside the solana_kit monorepo, workspace resolution uses local packages automatically.

Documentation #

Usage #

dApp: Simple session #

import 'package:solana_kit_mobile_wallet_adapter/solana_kit_mobile_wallet_adapter.dart';
import 'package:solana_kit_mobile_wallet_adapter_protocol/solana_kit_mobile_wallet_adapter_protocol.dart';

final authResult = await transact((wallet) async {
  // Authorize with the wallet.
  final auth = await wallet.authorize(
    identity: const AppIdentity(name: 'My dApp'),
    chain: 'solana:mainnet',
  );

  // Sign transactions.
  final signed = await wallet.signTransactions(
    payloads: [base64EncodedTransaction],
  );

  return auth;
});

dApp: Manual session control #

final scenario = LocalAssociationScenario();

try {
  final rawWallet = await scenario.start();
  final wallet = wrapWithKitApi(rawWallet);

  final auth = await wallet.authorize(
    identity: const AppIdentity(name: 'My dApp'),
    chain: 'solana:devnet',
  );

  final signed = await wallet.signTransactions(
    payloads: ['base64tx1', 'base64tx2'],
  );
} finally {
  await scenario.close();
}

Wallet: Handling requests #

class MyWalletCallbacks implements WalletScenarioCallbacks {
  @override
  void onAuthorizeRequest(AuthorizeDappRequest request) {
    // Show UI to approve/decline.
    request.completeWithAuthorize(
      accounts: [
        AuthorizedAccount(address: base64PublicKey, label: 'Main Account'),
      ],
      authToken: 'issued-token',
    );
  }

  @override
  void onSignTransactionsRequest(SignTransactionsRequest request) {
    // Sign the payloads.
    final signed = signPayloads(request.payloads);
    request.completeWithSignedPayloads(signed);
  }

  // ... implement other callbacks
}

final scenario = WalletScenario(
  walletName: 'My Wallet',
  config: const MobileWalletAdapterConfig(
    maxTransactionsPerSigningRequest: 10,
    optionalFeatures: ['solana:signTransactions'],
  ),
  callbacks: MyWalletCallbacks(),
);

await scenario.start();

Platform support #

Platform dApp (client) Wallet (server)
Android Supported Supported
iOS No-op No-op
Web N/A N/A

Use isMwaSupported() to check at runtime before calling MWA APIs.

Architecture #

This plugin uses a hybrid Dart + native approach:

  • Dart: All WebSocket handling, P-256 cryptography, session handshake, JSON-RPC messaging, and protocol logic (via solana_kit_mobile_wallet_adapter_protocol)
  • Android Kotlin: Intent launching (solana-wallet:// scheme) and wallet scenario bridge (MethodChannel)
  • iOS Swift: Empty no-op plugin that compiles cleanly

This maximizes code sharing, testability, and reuse of the pure Dart protocol package.

Example #

Use example/main.dart as a runnable starting point for solana_kit_mobile_wallet_adapter.

  • Import path: package:solana_kit_mobile_wallet_adapter/solana_kit_mobile_wallet_adapter.dart
  • This section is centrally maintained with mdt to keep package guidance aligned.
  • After updating shared docs templates, run docs:update from the repo root.

Maintenance #

  • Validate docs in CI and locally with docs:check.
  • Keep examples focused on one workflow and reference package README sections for deeper API details.
0
likes
150
points
48
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for the Solana Mobile Wallet Adapter protocol. Enables dApps to communicate with wallet apps for transaction signing on Android. iOS compiles but is a no-op.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, solana_kit_addresses, solana_kit_errors, solana_kit_keys, solana_kit_mobile_wallet_adapter_protocol, solana_kit_transactions, web_socket_channel

More

Packages that depend on solana_kit_mobile_wallet_adapter

Packages that implement solana_kit_mobile_wallet_adapter