What's MWA?
Mobile Wallet Adapter (MWA) is a communication protocol that enables secure interactions between decentralized applications (dApps) and wallet applications on mobile devices. It serves as the bridge that makes Solana’s mobile ecosystem work seamlessly.
The Core Problem
On traditional web platforms:
1
Web dApp ←→ Browser Extension Wallet (e.g., MetaMask)
Browser extensions can inject code into web pages through a shared JavaScript environment. However, mobile applications are isolated from each other, creating a communication gap:
1
Mobile dApp ←→ ??? ←→ Standalone Wallet App
MWA solves this by providing the missing communication layer:
1
Mobile dApp ←→ MWA Protocol ←→ Wallet Application
How MWA Works
Connection Flow
- Intent Broadcasting: dApp sends an MWA intent with
solana-wallet://
scheme - Wallet Selection: Android system displays a chooser dialog for installed wallets
- WebSocket Establishment: Selected wallet app establishes a persistent connection
- Secure Communication: Encrypted message exchange using AES-128-GCM
Technical Implementation
Android Integration:
1
2
3
4
5
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="solana-wallet" />
</intent-filter>
JavaScript API:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
const result = await transact(async (wallet) => {
// Authorization
const authResult = await wallet.authorize({
cluster: 'solana:devnet',
identity: {
name: 'My dApp',
uri: 'https://mydapp.com'
}
});
// Transaction signing
const signedTx = await wallet.signAndSendTransactions({
transactions: [myTransaction]
});
return signedTx;
});
Protocol Messages
MWA uses JSON-RPC 2.0 format:
Authorization Request:
1
2
3
4
5
6
7
8
9
10
11
12
{
"jsonrpc": "2.0",
"id": 1,
"method": "authorize",
"params": {
"identity": {
"name": "My dApp",
"uri": "https://mydapp.com"
},
"cluster": "solana:devnet"
}
}
Wallet Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"auth_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"accounts": [
{
"address": "DemoKeyPair111111111111111111111111111111111",
"label": "My Account"
}
]
}
}
Why iOS Doesn’t Support MWA
- Background Limitations: iOS suspends WebSocket connections when apps are backgrounded
- Intent System: No equivalent to Android’s intent disambiguation
- Sandbox Restrictions: Stricter inter-app communication policies
MWA Protocol Versions
MWA 1.0: Basic authorization and signing functionality
MWA 2.0: Current version featuring:
- Sign-in with Solana (SIWS) support
- Enhanced security
- Better error handling
- Multi-account support
Example: Before vs After MWA
Without MWA:
1
2
3
4
5
6
7
if (isPhantomWallet) {
await phantom.connect();
} else if (isSolflareWallet) {
await solflare.authorize();
} else if (isBackpackWallet) {
await backpack.init();
}
With MWA:
1
2
3
4
const result = await transact(async (wallet) => {
// Same API regardless of wallet
return await wallet.authorize(params);
});
Benefits and Limitations
Benefits
- Unified API across different wallet applications
- Secure key management without exposing private keys
- User-controlled wallet selection via Android’s intent system
- Persistent sessions with auth token caching
Limitations
- Android-only (iOS lacks intent disambiguation)
- Requires MWA-compatible wallets to be installed
- WebSocket dependency for persistent connections
Conclusion
MWA enables mobile Solana dApps to connect with wallets as seamlessly as web applications, but currently only works on Android due to platform limitations.