Implementing Cross-Chain Bridge (Bridge) in a Mobile Crypto Wallet
A cross-chain bridge is the most complex scenario in a mobile wallet. Funds leave Network A and appear in Network B. This process takes anywhere from minutes to several hours, leaving users in the dark without proper tracking implementation.
Integration Options: Bridge APIs
Building a custom bridge protocol from scratch is not a mobile wallet task. Ready-made solutions should be integrated:
Li.Fi (https://li.fi/) — an aggregator for bridges and swaps. A single API covers Stargate, Hop, Across, Squid, and dozens more. Route request example:
// iOS — routes via Li.Fi SDK
import LiFi
let lifi = LIFI()
let routesRequest = RoutesRequest(
fromChainId: 1, // Ethereum
toChainId: 137, // Polygon
fromTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
toTokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
fromAmount: "100000000" // 100 USDC (6 decimals)
)
let routes = try await lifi.getRoutes(request: routesRequest)
Squid Router — specializes in cross-chain swaps via Axelar. Works well for EVM ↔ Cosmos.
Stargate Finance — LayerZero protocol with direct integration via StargateFacet for USDC/USDT across major EVM networks.
Route Selection and Bridge Comparison
Li.Fi returns multiple routes with different parameters. Present to users:
| Route | Time | Fee | You'll receive |
|---|---|---|---|
| Stargate | ~5 min | $2.50 | 97.5 USDC |
| Hop Protocol | ~20 min | $1.80 | 98.2 USDC |
| Across | ~3 min | $3.10 | 96.9 USDC |
Default sorting is by maximum output. Provide a toggle for "faster" / "cheaper."
Transfer Tracking
After sending a transaction on Network A, the user receives txHash from the source chain. Funds will appear on the destination chain after finalization time, depending on the bridge mechanism.
Li.Fi provides a status API: GET /v1/status?txHash={hash}&fromChain={chainId}&toChain={chainId}&bridge={bridgeName}. Statuses: PENDING → DONE / FAILED.
// Android — polling bridge status
suspend fun pollBridgeStatus(txHash: String, fromChain: Int, toChain: Int): BridgeStatus {
repeat(180) { // 30 minutes * 10 sec
delay(10_000)
val status = lifiBridgeApi.getStatus(txHash, fromChain, toChain)
if (status.status == "DONE" || status.status == "FAILED") return status
}
return BridgeStatus(status = "TIMEOUT")
}
Polling in the background via WorkManager (Android) or BackgroundTasks (iOS) ensures users receive a push notification upon completion, even if the app is closed.
Handling Stuck Transfers
Some bridges don't have automatic refunds on error. Li.Fi provides a recoverTx API for certain cases. Store full bridge transaction history locally with the ability to re-check and link to bridge support.
Timeline: Integration via an aggregator (Li.Fi or Squid) with one supported route — 1–2 weeks. Multi-aggregator system with route selection, background tracking, and history — 3–6 weeks.







