External Wallet Adapter
interface ExternalWalletAdapter
Protocol for integrating external wallet adapters for multi-signer support.
External wallet adapters enable signing with external wallets like Freighter or Albedo for multi-signature smart accounts. They handle wallet connection, signature collection, and wallet reconnection.
Example implementation:
class FreighterAdapter : ExternalWalletAdapter {
override suspend fun connect(): ConnectedWallet? {
// Show wallet selection modal
return ConnectedWallet(address = "G...", walletId = "freighter", walletName = "Freighter")
}
override suspend fun signAuthEntry(
preimageXdr: String,
options: SignAuthEntryOptions?
): SignAuthEntryResult {
// Decode preimage, hash with SHA-256, sign with Ed25519
val preimageBytes = Base64.decode(preimageXdr)
val hash = sha256(preimageBytes)
val signature = freighterSign(hash, options?.address)
return SignAuthEntryResult(
signedAuthEntry = Base64.encode(signature),
signerAddress = options?.address
)
}
}Content copied to clipboard
Functions
Link copied to clipboard
Checks if a specific address has a connected wallet that can sign for it.
Link copied to clipboard
Connects to the external wallet.
Link copied to clipboard
Disconnects all external wallets.
Link copied to clipboard
Disconnects a specific wallet by address.
Link copied to clipboard
Gets all currently connected wallets.
Link copied to clipboard
Gets wallet info for a specific address.
Link copied to clipboard
Reconnects to a previously connected wallet by its wallet ID.
Link copied to clipboard
abstract suspend fun signAuthEntry(preimageXdr: String, options: SignAuthEntryOptions? = null): SignAuthEntryResult
Signs an authorization preimage with the external wallet.