Overview
This guide outlines how to integrate and use external cryptocurrency wallets with the ParaSwift SDK. With the unified wallet architecture, the Swift SDK has removed all blockchain-specific dependencies and now provides a streamlined approach to external wallet connectivity. The SDK supports external wallets like MetaMask through deep-linking protocols and provides built-in authentication and transaction signing capabilities. You can also sign users in to Para with their external wallet usingauthenticateWithExternalWallet.
Unified Wallet Architecture: The Swift SDK uses only BigInt for handling blockchain values and avoids blockchain-specific package dependencies such as web3swift or solana-swift. This provides a cleaner, more maintainable architecture while still supporting all necessary external wallet operations.The SDK now has minimal dependencies:
- BigInt: For handling large blockchain numbers (Wei, gas values, etc.)
- PhoneNumberKit: For phone number validation in authentication flows
Deep Linking
The ParaSwift SDK communicates with other apps via deep linking. To enable deep linking for your application, you’ll need to configure your app appropriately.Configure URL Schemes
First, you need to configure your app to handle custom URL schemes:- Open your app’s Info.plist file
- Add a new entry for
LSApplicationQueriesSchemesas an array - Add the URL schemes of supported wallets as strings to this array
Configure URL Types
Next, you need to set up URL Types to handle callbacks from external wallets:- In Xcode, select your app target
- Go to “Info” tab
- Expand “URL Types”
- Click the ”+” button to add a new URL Type
- Set the “Identifier” to your app’s bundle identifier
- Set the “URL Schemes” to a unique identifier for your app
MetaMask Connector
Setup
Create and initialize the MetaMask connector with your app’s configuration:Handle Deep Links
Handle incoming deep links from MetaMask by adding a URL handler in your SwiftUI app:The deep link handling has been simplified to use a static method. You no longer need to maintain a MetaMaskConnector instance at the app level just for handling deep links.
Connecting
To connect to MetaMask and retrieve the user’s accounts:Automatic connection-only session: After a successful connection, the MetaMask connector calls
loginExternalWallet with the connected address, which starts a connection-only session for that wallet. To sign the user in to Para with the wallet, call authenticateWithExternalWallet as described in External Wallet Authentication with Para.Sign Message
To request a signature for a message from MetaMask:Send Transaction
To send a transaction through MetaMask using the EVMTransaction model:Properties
The MetaMask connector provides several useful properties:Supported Networks
The MetaMask connector works with any EVM-compatible network that MetaMask supports. Common networks include:Working with BigUInt Values
Since the Swift SDK now uses BigInt for handling blockchain values, here are some utility patterns for working with Ether and Wei conversions:These utility functions help you convert between human-readable Ether amounts and the Wei values required by the blockchain. Always validate decimal inputs to prevent runtime crashes.
Advanced Configuration
Customizing MetaMask Connection
You can customize various aspects of the MetaMask connection by modifying the MetaMaskConfig:Working with Different Networks
MetaMask supports multiple networks. You can check the current network and adjust your app’s behavior accordingly:External Wallet Authentication with Para
Para supports signing in with an external wallet like MetaMask, so users can log into Para with the wallet they already have.Connection-only vs. sign-in
There are two ways to tell Para about an external wallet:- Connection-only (
loginExternalWallet(wallet:)with the defaultisConnectionOnly: true). Para records the connected address for the session without signing the user in to a Para account. This is whatMetaMaskConnector.connect()does automatically. - Sign-in (
authenticateWithExternalWallet, recommended). The user signs in to a Para account with the wallet. On Para’s updated authentication flow, the wallet proves it controls the address by signing a sign-in message. This is a verify-only sign-in: Para doesn’t create an embedded Para wallet for the user, and the external wallet stays the user’s wallet.
Sign In with authenticateWithExternalWallet (Recommended)
Call authenticateWithExternalWallet(address:type:provider:chainId:uri:signMessage:signCosmosMessage:) with the wallet’s address and a signMessage closure that signs a message with that wallet and returns the signature. It returns an AuthenticationResult with the user’s userId and whether this sign-in created the account (isNewUser).
Para decides which sign-in experience runs for your app, so build for both:
- Para’s updated authentication flow. The SDK asks your
signMessageclosure (signCosmosMessagefor a Cosmos wallet) to sign a sign-in message (Sign-In With Ethereum for EVM wallets, a plain-text message for other chains), then verifies the signature, and the user is signed in right away. This is the same for new and returning accounts: no passkey, password, or Para-hosted page is involved, and no embedded Para wallet is created. The session proves control of the external wallet only, so it can’t sign with any embedded Para wallets the account already has. - Address sign-in without a signature. The SDK runs the existing
loginExternalWalletsign-in (withisConnectionOnly: false), and neither signing closure is called.
MetaMaskConnector.connect() is active, authenticateWithExternalWallet logs it out before signing in, on both flows, so you can connect first and then sign in.
ExternalWalletLoginView.swift
signMessageswitches apps. For MetaMask,signMessage(_:account:)opens MetaMask to approve the signature and returns when MetaMask hands back to your app, so your deep link handling must be in place. Throw fromsignMessageto cancel sign-in.- The message names a domain. The sign-in message names a URI, and its domain is what the wallet shows the user. By default it’s Para’s origin. A URI you pass in
uri:is used only when your app’s allowed origins in the Developer Portal include both its origin and Para’s origin; otherwise Para’s origin is used. chainIdis optional. Pass the chain the wallet is on, for examplemetaMaskConnector.chainId. For EVM wallets the message defaults to Ethereum mainnet.- A new user has no embedded Para wallet. A verify-only sign-in creates no Para wallet shares. Sign transactions with the external wallet, for example
metaMaskConnector.sendTransaction(_:account:).
Supported wallet types and signature formats
On Para’s updated authentication flow,authenticateWithExternalWallet supports EVM, Solana, and Cosmos wallets. Stellar wallets aren’t supported yet: the signature can’t be verified, so the call throws. Return the signature in the format Para verifies:
On Para’s updated authentication flow, a Cosmos sign-in needs
signCosmosMessage, because Para verifies the signature against the signer and public key. Without it the call throws before asking the wallet to sign. signMessage isn’t called for a Cosmos wallet when signCosmosMessage is provided:
cosmosWallet stands for whichever Cosmos wallet integration your app uses; the SDK doesn’t include a Cosmos wallet connector.
Handle errors
authenticateWithExternalWallet throws when sign-in can’t finish. Common cases:
- A user is already signed in. On Para’s updated authentication flow the call throws
ParaError.error("A user is already signed in. Call logout() before signing in again."). Calllogout()first. A connection-only session doesn’t count: the SDK logs it out for you. - The user cancels. Throw from
signMessage(orsignCosmosMessage) when the user rejects the signature, and the call rethrows that error. - The signature can’t be verified. For example, the wallet signed with a different address, or returned the signature in the wrong format.
- Two-factor authentication is required. When Para’s updated authentication flow isn’t running for your app, the call signs in through
loginExternalWalletand throwsParaTwoFactorRequiredErrorfor an account that must complete login 2FA. See .
Manual Alternative: loginExternalWallet
loginExternalWallet(wallet:) remains available. Pass isConnectionOnly: false to sign in with the wallet address. It doesn’t ask the wallet for a signature and doesn’t use Para’s updated authentication flow, so new integrations should prefer authenticateWithExternalWallet. It throws ParaTwoFactorRequiredError when the account must complete login 2FA, which this method can’t host.
Complete loginExternalWallet example
Complete loginExternalWallet example
Here’s a complete example showing external wallet authentication: