Skip to main content

solana_kit_wallet_adapter 0.3.1 copy "solana_kit_wallet_adapter: ^0.3.1" to clipboard
solana_kit_wallet_adapter: ^0.3.1 copied to clipboard

Flutter wallet controller for Wallet Standard and Mobile Wallet Adapter.

solana_kit_wallet_adapter #

pub package CI coverage

Flutter wallet discovery, connection state, and Solana Kit signer integration. Browser builds discover installed Wallet Standard wallets; Android builds expose locally installed wallets through Mobile Wallet Adapter.

Installation #

dependencies:
  solana_kit_wallet_adapter: ^0.1.0

Usage #

import 'package:solana_kit_wallet_adapter/solana_kit_wallet_adapter.dart';
import 'package:solana_kit_wallet_standard/solana_kit_wallet_standard.dart';

Future<WalletAccountSigner> connectFirstWallet() async {
  final registry = createDefaultWalletRegistry(
    appIdentity: const WalletAppIdentity(name: 'My app'),
    chain: SolanaChainId.devnet,
  );
  final wallets = WalletController(registry, chain: SolanaChainId.devnet);

  await wallets.initialize();
  await wallets.connect(wallets.state.wallets.first);

  return wallets.createSigner();
}

WalletController is a ChangeNotifier, so it works with Flutter's built-in ListenableBuilder and any state-management package. The adapter has no dependency on the optional widget package.

Pending authorization is invalidated when you disconnect, switch wallets, remove a wallet from the registry, or dispose the controller. A superseded connect future rejects with WalletStandardErrorCode.disconnected; its completion cannot restore an old selected account. Disconnect clears the selected account immediately, before the backend finishes. Create a fresh signer after each connection or account change.

Platform behavior #

  • Web: implements the Wallet Standard wallet-standard:register-wallet and wallet-standard:app-ready event handshake, including wallets registered after application startup.
  • Android: uses the Solana Mobile Wallet Adapter protocol to authorize, sign, send, disconnect, and complete Sign In With Solana.
  • Other native platforms: returns an empty registry. Applications can supply their own WalletRegistry implementation or use a browser-based flow.

Mobile wallet signing batches must use one authorized account. Transaction chains must match the chain used to authorize the mobile wallet, and every sign-and-send input in a batch must use equivalent submission options. Submit requests with different accounts or policies separately; mismatched batches are rejected before any backend signing or submission. Disconnect immediately revokes local accounts even if backend cleanup fails. Pending or superseded connect/sign-in operations cannot restore authority.

Native message signing validates the returned message envelope and exposes the extracted 64-byte signature; malformed envelopes and changed message bytes are rejected. Every signature the mobile wallet returns — over messages, signed transactions, submitted transactions, and Sign In With Solana proofs — is verified against the authorized account's public key before it reaches the caller, and a sign-in proof is rejected unless its address belongs to the accounts the same authorization returned.

Native sign-in also requires the signed bytes to match the canonical SIWS message for the request, including the requested address, nonce, domain, URI, statement, version, chain ID, timestamps, request ID, and ordered resources. The wallet may select the domain and account when those inputs are omitted. A replayed proof for a different challenge or a malformed message fails with WalletStandardErrorCode.invalidResponse. Applications remain responsible for choosing a fresh nonce and enforcing their authentication expiry policy.

Browser signing verifies one result per input and rejects changed transaction or message bytes, invalid Ed25519 signatures, and unsupported signature algorithms. Sign-in proofs must use an authorized account and match every supplied SIWS field, including the nonce and resources. Offchain proofs must preserve the version-one message content and required signers. Submission signatures must identify the requested transaction; use RPC confirmation to establish whether it landed on chain.

Key APIs #

  • WalletController and immutable WalletAdapterState
  • createDefaultWalletRegistry
  • WalletAccountSigner
  • MobileWallet, MobileWalletRegistry, and MobileWalletBackend
  • WalletAppIdentity