Connect a wallet on Seeker
Yesterday we had three tabs and a devnet ping. Today we add the thing that makes Solana mobile different from a website: the wallet is on the phone. Mobile Wallet Adapter lets your app request a connection, sign messages, and send transactions — without ever seeing a private key.
1How MWA works
Your app does not hold keys. It sends an Android intent: “I need a wallet.” Seed Vault on Seeker, or any other MWA-compatible wallet, opens. The person taps approve. Your app gets back a public key. That is the whole handshake. Docs: docs.solanamobile.com.
2Install
The Solana Mobile Expo template already includes these. If you are wiring them yourself:
npm install @solana-mobile/mobile-wallet-adapter-protocol-web3js @solana/web3.js
3Connect button
The template hook is useMobileWallet in src/utils/useMobileWallet.tsx. connect() calls transact, then authorizeSession, and returns an Account with a publicKey (PublicKey from @solana/web3.js). Show the first four and last four characters of the base58 string.
import { Button, Text } from "react-native-paper";
import { useMobileWallet } from "../utils/useMobileWallet";
import { useAuthorization } from "../utils/useAuthorization";
const { connect } = useMobileWallet();
const { selectedAccount } = useAuthorization();
async function onConnect() {
try {
const account = await connect();
const base58 = account.publicKey.toBase58();
const short = base58.slice(0, 4) + "…" + base58.slice(-4);
console.log(short);
} catch (error) {
console.warn("Connect failed", error);
}
}
<Button mode="contained" onPress={onConnect}>Connect</Button>
{selectedAccount ? (
<Text>
{selectedAccount.publicKey.toBase58().slice(0, 4)}
…
{selectedAccount.publicKey.toBase58().slice(-4)}
</Text>
) : null}
useAuthorization keeps the chosen account. After a successful connect(), selectedAccount is that same account. Put this on the Diagnostics tab next to yesterday’s RPC chip.
4Common errors
- No wallet found — install a wallet APK on the emulator (Seed Vault on a Seeker, or any MWA wallet on an AVD).
- Connection refused — make sure the wallet app is running in the background, then try Connect again.
- User rejected — expected. Catch it and leave the UI in the disconnected state. Do not crash.
5Checkpoint
Module 03 is a first transaction: airdrop on devnet, then sign and send a tiny transfer to yourself.