The Para Swift SDK provides a comprehensive toolkit for integrating non-custodial wallet functionality, passkey-based authentication, and blockchain interactions into your native iOS applications.
ParaManager Class
The ParaManager
class is the central component for managing user authentication, wallet operations, and session state.
Properties
An array of Wallet
objects currently associated with the authenticated user. This list is updated after operations like fetchWallets()
or createWallet()
.
The current session state of the Para SDK (e.g., .unknown
, .inactive
, .active
, .activeLoggedIn
).
The environment configuration for the Para SDK (e.g., .beta
, .prod
).
The API key used for authenticating with Para services.
Indicates if the ParaManager
and its underlying WebView are initialized and ready to process requests.
Initialization
init(environment:apiKey:deepLink:)
Initializes a new ParaManager
instance.
The Para environment to use (e.g., .beta
, .prod
).
Optional. Your app’s custom URL scheme (e.g., “yourapp://”). Defaults to the app’s bundle identifier. Used for OAuth and other redirection flows.
Authentication Methods
Starts the authentication (signup or login) process for a user with the specified email or phone number.
The authentication identifier: .email(String)
for email or .phone(String)
for a full phone number (e.g., “+15551234567”).
An AuthState
object indicating the next step in the flow (e.g., .verify
for new users, .login
for existing users).
handleVerificationCode(verificationCode:)
Submits the verification code (OTP) received by the user via email or SMS.
The verification code entered by the user.
An AuthState
object, typically with stage == .signup
, indicating the user is verified and needs to choose a signup method (passkey or password).
Requests a new verification code to be sent to the user’s email or phone.
isSignupMethodAvailable(method:authState:)
Checks if a specific signup method (passkey or password) is available based on the current AuthState
.
The signup method to check (e.g., .passkey
).
The current AuthState
(should have stage == .signup
).
true
if the method is available, false
otherwise.
handleSignup(authState:method:authorizationController:webAuthenticationSession:)
Completes the signup process for a new, verified user using the chosen method (passkey or password). This typically includes creating a passkey/password and the first wallet.
The current AuthState
(must have stage == .signup
).
The chosen signup method (.passkey
or .password
).
An ASAuthorizationController
instance for handling Passkey UI operations.
A WebAuthenticationSession
conforming object for handling web-based authentication (e.g., password setup).
isLoginMethodAvailable(method:authState:)
Checks if a specific login method (passkey or password) is available for an existing user.
The login method to check (e.g., .passkey
).
The current AuthState
(should have stage == .login
).
true
if the method is available, false
otherwise.
handleLogin(authState:authorizationController:webAuthenticationSession:)
Logs in an existing user, automatically determining and using the preferred available method (passkey or password).
The current AuthState
(must have stage == .login
).
An ASAuthorizationController
instance for Passkey UI.
A WebAuthenticationSession
for web-based login (e.g., password).
loginWithPasskey(authorizationController:email:phone:)
Logs in a user directly using their passkey.
An ASAuthorizationController
instance for Passkey UI.
Optional. The user’s email if known, to help filter passkeys.
Optional. The user’s full phone number if known, to help filter passkeys. If both email and phone are nil, the system prompts for any available passkey.
generatePasskey(identifier:biometricsId:authorizationController:)
Generates and registers a new passkey for the user. Typically called during signup when authState.stage == .signup
and SignupMethod.passkey
is chosen.
The user’s identifier (email or full phone number).
The passkeyId
obtained from AuthState.passkeyId
when authState.stage == .signup
.
An ASAuthorizationController
instance for Passkey UI.
presentPasswordUrl(_ url:webAuthenticationSession:)
Presents a web URL (typically for password setup/login) using a web authentication session.
The URL to present (e.g., authState.passwordUrl
).
A WebAuthenticationSession
conforming object.
The callback URL if authentication was successful via direct callback, or nil on failure/cancellation.
handleOAuth(provider:webAuthenticationSession:authorizationController:)
Initiates and handles the entire OAuth flow with the specified provider (e.g., Google, Apple, Discord).
This includes user authentication with the provider, Para account lookup/creation, and passkey setup if it’s a new Para user.
The OAuth provider to use (e.g., .google
).
A WebAuthenticationSession
for handling the OAuth web flow.
An ASAuthorizationController
for potential passkey setup.
result
(success: Bool, errorMessage: String?)
A tuple indicating if the OAuth flow was successful and an optional error message.
loginExternalWallet(wallet:)
Logs into Para using an externally managed wallet (e.g., MetaMask).
Information about the external wallet, including its address and type.
Session Management Methods
Checks if there is an active session and the user is fully authenticated (e.g., passkey/password set up).
true
if the user is fully logged in, false
otherwise.
Checks if there is any active session with Para, even if the user is not fully logged in (e.g., pending verification).
true
if there is any active session, false
otherwise.
Exports the current session for backup or transfer purposes.
The session data as a string that can be saved and restored later.
Logs out the current user and clears all session data.
getCurrentUserAuthDetails()
Gets the current user’s persisted authentication details.
The current user’s authentication state, or nil if no user is authenticated. The ‘stage’ will be set to ‘login’ for active sessions.
Wallet Management Methods
Retrieves all wallets associated with the current user.
An array of Wallet
objects associated with the user.
createWallet(type:skipDistributable:)
Creates a new wallet for the authenticated user. This method initiates wallet creation and refreshes the internal wallets
list. Observe the paraManager.wallets
property for the new wallet.
The type of wallet to create (e.g., .evm
, .solana
, .cosmos
).
Whether to skip the distributable key generation step.
Retrieves the email of the currently authenticated user, if available and the session was initiated with an email.
The user’s email address.
distributeNewWalletShare(walletId:userShare:)
(Advanced) Distributes a new share for an existing wallet.
The user share to distribute.
Signing Methods
signMessage(walletId:message:timeoutMs:)
Signs an arbitrary message using the specified wallet.
The ID of the wallet to use for signing.
The raw message string to sign. The SDK will Base64-encode this string before signing.
Optional. Timeout for the signing operation in milliseconds.
The resulting signature as a hex string.
signTransaction(walletId:rlpEncodedTx:chainId:timeoutMs:)
Signs an RLP-encoded EVM transaction string using the private key of the specified wallet.
The ID of the EVM wallet to use for signing.
The RLP-encoded transaction as a hex string. The SDK will Base64-encode this string.
The chain ID of the EVM network.
Optional. Timeout for the signing operation in milliseconds.
The resulting transaction signature as a hex string.
Two-Factor Authentication (2FA) Methods
Initiates the setup process for 2FA.
Returns .alreadySetup
if 2FA is already configured, or .needsSetup(uri: String)
containing the URI to be displayed in an authenticator app (e.g., as a QR code).
enable2fa(verificationCode:)
Enables 2FA for the user after they have scanned the URI and entered the code from their authenticator app.
The 2FA code from the user’s authenticator app.
ParaEvmSigner Class
The ParaEvmSigner
class provides a convenient way to sign and send EVM transactions using a Para-managed wallet. It interacts with an EVM-compatible JSON-RPC endpoint.
Initialization
init(paraManager:rpcUrl:walletId:)
Initializes a new ParaEvmSigner
instance.
An initialized ParaManager
instance.
The JSON-RPC endpoint URL for the EVM network.
Optional. The ID of the EVM wallet to use. If nil
, selectWallet(walletId:)
must be called before signing.
Methods
Selects or switches the active EVM wallet for this signer instance.
The ID of the EVM wallet to use.
Signs an arbitrary message string using the selected EVM wallet.
The raw message string to sign.
The resulting signature as a hex string.
signTransaction(transactionB64:)
Signs a pre-formatted, Base64-encoded EVM transaction.
The Base64-encoded EVMTransaction
object. Use evmTransaction.b64Encoded()
.
The signed transaction as a hex string, ready to be broadcast.
sendTransaction(transactionB64:)
Signs and broadcasts an EVM transaction to the network via the configured RPC URL.
The Base64-encoded EVMTransaction
object. Use evmTransaction.b64Encoded()
.
The response from the RPC node, typically containing the transaction hash. (e.g., {"jsonrpc":"2.0","id":1,"result":"0x..."}
)
ParaSolanaSigner Class
The ParaSolanaSigner
class facilitates signing and sending Solana transactions using a Para-managed wallet, interacting with a Solana JSON-RPC endpoint.
Initialization
init(paraManager:rpcUrl:walletId:)
Initializes a new ParaSolanaSigner
instance.
An initialized ParaManager
instance.
The JSON-RPC endpoint URL for the Solana network.
Optional. The ID of the Solana wallet to use. If nil
, selectWallet(walletId:)
must be called.
Methods
Selects or switches the active Solana wallet for this signer instance.
The ID of the Solana wallet to use.
Gets the current wallet’s public key.
The Solana public key for the selected wallet.
Gets the SOL balance for this wallet.
Signs arbitrary bytes (for demo/testing purposes).
Signs a Solana transaction using the bridge.
The SolanaTransaction to sign.
The base64 encoded signed transaction.
Sends a transaction to the network using the bridge.
The SolanaTransaction to send.
The transaction signature.
The MetaMaskConnector
class enables integration with MetaMask wallet for external wallet operations and authentication.
Properties
Indicates whether the connector is currently connected to MetaMask.
Array of connected MetaMask account addresses.
The current chain ID from MetaMask (e.g., “0x1” for Ethereum mainnet, “0xaa36a7” for Sepolia).
Initialization
init(para:appUrl:config:)
Initializes a new MetaMaskConnector
instance.
The ParaManager instance.
Your app’s URL scheme for deep link callbacks.
Configuration object containing app metadata.
Methods
Processes incoming deep link URLs from MetaMask responses.
The incoming URL to process.
Initiates connection to MetaMask and requests account access. This method is async throws
. Upon successful connection, the accounts
, chainId
, and isConnected
properties of the MetaMaskConnector
instance are updated. ParaManager.loginExternalWallet
is also called internally.
Requests MetaMask to sign a message with the specified account.
The message string to be signed.
The account address to use for signing.
The resulting signature from MetaMask.
sendTransaction(_:account:)
Sends a transaction through MetaMask using the specified account.
transaction
EVMTransaction or [String: String]
The transaction object or dictionary containing transaction parameters.
The account address to use for the transaction.
The transaction hash returned by MetaMask.
Error Types
The main error type for Para SDK operations.
An error occurred while executing JavaScript bridge code.
The JavaScript bridge did not respond in time.
A general error occurred.
Feature not implemented yet.
Errors specific to ParaSolanaSigner operations.
Invalid wallet type - expected Solana wallet.
Wallet address is missing or invalid.
signingFailed(underlyingError: Error?)
Signing operation failed.
networkError(underlyingError: Error?)
Network operation failed.
Invalid signature format.
transactionCompilationFailed(underlyingError: Error?)
Transaction compilation failed.
Errors specific to MetaMask connector operations.
Another MetaMask operation is already in progress.
Failed to construct a valid URL for MetaMask communication.
Received an invalid or unexpected response from MetaMask.
metaMaskError(code: Int, message: String)
An error reported by the MetaMask app itself (e.g., user rejection code 4001).
MetaMask app is not installed on the device.
AuthorizationHandlingError
Errors related to authorization handling in external wallet operations.
Invalid response received from authorization process.
Authorization was cancelled by the user.
Type Definitions
AuthState
Authentication state returned by authentication operations.
The stage of authentication (.verify
, .signup
, .login
).
The Para userId for the currently authenticating user.
Email address if using email auth.
Phone number if using phone auth.
Display name for the authenticating user.
Profile picture URL for the authenticating user.
Username for the authenticating user.
URL for passkey authentication.
URL for passkey authentication on a known device.
URL for password authentication.
Biometric hints for the user’s devices.
Auth
Authentication type for initiateAuthFlow method.
Email-based authentication.
Phone-based authentication with full phone number including country code.
OAuthProvider
Supported OAuth provider types for authentication.
Google authentication provider.
Discord authentication provider.
Apple authentication provider.
SignupMethod & LoginMethod
The possible methods for signup when the stage is .signup.
The possible methods for login when the stage is .login.
Passkey login on a known device.
Configuration object for MetaMask connector initialization.
The name of your application as displayed in MetaMask.
Your application’s identifier (typically the bundle identifier).
The API version to use (e.g., “1.0”).