Swift library for integrating Solana wallets into iOS and macOS apps via deeplinks.
SolanaWalletAdapterKit simplifies wallet connections, transaction signing, and message signing while supporting multiple wallet providers. It provides a type-safe transaction builder, encrypted deeplink communication, persistent sessions via Keychain, built-in programs, and async/await RPC client access.
- Multi-wallet support: Phantom, Solflare, Backpack
- Type-safe transaction builder with DSL
- Encrypted deeplink communication (Diffie-Hellman)
- Persistent sessions via Keychain
- Built-in programs: System, Token, AssociatedToken, Memo
- Async/await RPC client for Solana
- iOS 14.0+
- macOS 11.0+
- Swift 6.2+
- Xcode 16.0+
Add the package via Swift Package Manager:
dependencies: [
.package(url: "https://github.com/The-SolShare-Team/SolanaWalletAdapterKit.git", from: "1.0.0")
]import SolanaWalletAdapterKit
import SolanaRPC
import SolanaTransactionsAdd to Info.plist in your app:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>yourapp</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>phantom</string>
<string>solflare</string>
<string>backpack</string>
</array>Register your app's callback scheme in your app's main Swift file and add a URL handler:
SwiftUI:
import SwiftUI
import SolanaWalletAdapterKit
@main
struct YourApp: App {
init() {
// Register callback Scheme
SolanaWalletAdapter.registerCallbackScheme("yourapp")
}
var body: some Scene {
WindowGroup {
// Add a URL handler to your ContentView:
ContentView()
.onOpenURL { url in
if SolanaWalletAdapter.handleOnOpenURL(url) { return }
}
}
}
...
UIKit:
import UIKit
import SolanaWalletAdapterKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Register callback scheme
SolanaWalletAdapter.registerCallbackScheme("yourapp")
return true
}
// Add a URL handler
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return SolanaWalletAdapter.handleOnOpenURL(url)
}
...
}import SolanaWalletAdapterKit
import SolanaRPC
// Create wallet
let appIdentity = AppIdentity(name: "My App", url: URL(string: "https://myapp.com")!, icon: "icon.png")
var wallet = PhantomWallet(for: appIdentity, cluster: .mainnet)
// Connect
try await wallet.connect()
// Build and send transaction
let rpc = SolanaRPCClient(endpoint: .mainnet)
let blockhash = try await rpc.getLatestBlockhash().blockhash
let tx = try Transaction(feePayer: wallet.publicKey!, blockhash: blockhash) {
SystemProgram.transfer(from: wallet.publicKey!, to: "Recipient...", lamports: 1_000_000)
}
let result = try await wallet.signAndSendTransaction(transaction: tx)let tx = try Transaction(feePayer: wallet.publicKey!, blockhash: blockhash) {
TokenProgram.transfer(
source: sourceTokenAccount,
destination: destTokenAccount,
authority: wallet.publicKey!,
amount: 100_000_000
)
}let message = "Sign this".data(using: .utf8)!
let result = try await wallet.signMessage(message: message, display: .utf8)
print(result.signature)let manager = WalletConnectionManager(
availableWallets: [PhantomWallet.self, SolflareWallet.self],
storage: KeychainStorage()
)
// Recover saved connections
try await manager.recoverWallets()
// Connect and save
try await manager.pair(PhantomWallet.self, for: appIdentity, cluster: .mainnet)Full API references can be found here
A demo application can be found in the accompanying repository DemoAppSolanaWalletAdapterKit that showcases core functionality.
See repository license