> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-mobile-sdk/android/guides/wallet-integration.md).

# Wallet Integration

The SDK never holds a private key. Your app implements a host signer interface for its wallet type, and the SDK calls it to read the address and request signatures.

### HostWallet (EVM)

```kotlin
class WalletHost(private val wallet: YourWalletImplementation) : HostWallet {
    override fun address(): String = wallet.address
    override fun chainID(): Long = wallet.chainId
    override fun personalSign(message: String): String = wallet.personalSign(message)
    override fun sendTransaction(toHex: String, dataHex: String, valueDec: String, gasLimit: Long): String =
        wallet.sendTransaction(toHex, dataHex, valueDec, gasLimit)
    override fun switchChain(chainID: Long) = wallet.switchChain(chainID)
}
```

| Method            | Purpose                                                |
| ----------------- | ------------------------------------------------------ |
| `address`         | The wallet's public address.                           |
| `chainID`         | The wallet's current chain id.                         |
| `personalSign`    | EIP-191 personal\_sign of a message.                   |
| `sendTransaction` | Sign and broadcast a transaction; returns the tx hash. |
| `switchChain`     | Switch the wallet to another chain.                    |

### HostSolanaSigner

```kotlin
class SolanaHost(private val wallet: YourSolanaWallet) : HostSolanaSigner {
    override fun publicKey(): String = wallet.publicKey
    override fun signMessage(message: ByteArray): ByteArray = wallet.signMessage(message)
    override fun signTransaction(tx: ByteArray): ByteArray = wallet.signTransaction(tx)
}
```

### HostTronSigner

```kotlin
class TronHost(private val wallet: YourTronWallet) : HostTronSigner {
    override fun address(): String = wallet.address
    override fun signMessage(message: String): ByteArray = wallet.signMessage(message)
    override fun signTxHash(txHash: ByteArray): ByteArray = wallet.signTxHash(txHash)
}
```

### Connecting

```kotlin
client.connect(WalletHost(yourWallet))                    // EVM
client.connectSolana(SolanaHost(yourWallet), solanaChainId) // Solana
client.connectTron(TronHost(yourWallet), tronChainId)       // Tron
```

### Best Practices

#### 1. Never let the key reach the SDK

The host only returns an address and signatures. Keep the private key in your wallet/keystore; the SDK never asks for it.

#### 2. Let signing failures throw

Host methods declare `throws Exception`. If signing fails, throw - do not return an empty string, which the SDK would treat as a valid signature.

```kotlin
override fun personalSign(message: String): String = wallet.personalSign(message)  // throws on failure
```

#### 3. Match the host to the chain

Implement `HostWallet` for EVM, `HostSolanaSigner` for Solana, `HostTronSigner` for Tron, and connect with the matching method.
