Solflare Deeplinking
Integrate Solflare wallet deeplinking to enable secure transaction signing in your mobile application. This guide shows you how to prepare transactions with Arrow API and send them to Solflare for signing.
Prerequisites
Before you begin, make sure you have:
- Set up the Deeplinking Utilities
- An Arrow API key for generating transactions
- Solflare wallet installed on the user's device
- A configured redirect scheme for your app (e.g.,
solana-yatori-nuxt-ionic-mobile://)
Connecting to Solflare
Before you can send transactions, you need to establish a connection with Solflare. This involves initiating a connection request and handling the response when Solflare redirects back to your app.
Note: The code examples below are from our Nuxt/Ionic Mobile Template. Check out the template repository for the complete implementation.
1. Initiate Connection
Create a connection function that opens Solflare with your dApp's encryption public key and redirect information:
Important notes:
app_urlmust be an HTTPS universal associated deeplink (not a URL scheme). Set this up with AppIcon and metadata for your app.redirect_linkuses your app's unique URL scheme (e.g.,solana-yatori-nuxt-ionic-mobile://), configured in Xcode for iOS or AndroidManifest.xml for Android.
2. Handle Connection Response
Set up a deep link handler to process the connection response from Solflare. This handler decrypts the connection data and stores the session information:
The handler processes two types of deep links:
- Connection: When the path matches
onConnectSolflare, it decrypts and stores the session data, including the wallet's public key and connected address. - Transaction Response: When the path matches
signAndSendUsdc, it decrypts the signed transaction signature.
Solflare Deeplink URL Format
Solflare uses the following URL scheme for signing and sending transactions:
Parameters
| Parameter | Description |
|---|---|
dapp_encryption_public_key | Base58-encoded public key of your dApp's encryption keypair |
cluster | Solana cluster (e.g., "mainnet-beta", "devnet") |
nonce | Base58-encoded nonce used for encryption |
redirect_link | Your app's deep link scheme where Solflare will redirect after signing |
payload | Base58-encoded encrypted transaction payload |
Complete Implementation
Here's a complete example of preparing and sending a transaction with hash included to Solflare:
Step-by-Step Breakdown
1. Get Transaction from Arrow API
Use Arrow API to generate a serialized, unsigned transaction. The transaction includes the latest blockhash automatically.
2. Prepare Payload
Create a payload object containing the session information and the base58-encoded transaction bytes.
3. Derive Shared Secret
Use your dApp's secret key and Solflare's public key to derive a shared secret for encryption.
4. Encrypt Payload
Encrypt the payload using the shared secret and a randomly generated nonce.
5. Build Deeplink URL
Construct the Solflare deeplink URL with all required parameters, including your app's redirect scheme.
6. Navigate to Solflare
Open the deeplink URL, which will launch Solflare. After the user signs, Solflare will redirect back to your app using the redirect_link.
Handling the Response
When Solflare redirects back to your app, you'll receive the signed transaction. Handle it in your app's route handler:
Related Resources
- Deeplinking Utilities - Shared encryption and keypair utilities
- Token Transfer with Memo + Blockhash - Arrow API endpoint documentation
