Day 2 drops at 10:00 UTC on October 3.

Reveals in …

← Course home
← Module 01 Module 02 · about 60 min

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

5Checkpoint

You're done when: tapping Connect opens a wallet prompt, approving it shows your public key in the Diagnostics tab.