WalletConnect Kotlin SDK, implements 1.0.0 websocket based protocol.
- Connect and disconnect
- Approve / Reject / Kill session
- Approve and reject
eth_sign
/personal_sign
/eth_signTypedData
- Approve and reject
eth_signTransaction
/eth_sendTransaction
- Approve and reject
bnb_sign
(binance dex orders) - session persistent / recovery
- switch evm chain by chainId
wallet_switchEthereumChain
- switch to aptos chain by chainName
wallet_switchEthereumChain
- Approve and reject
aptos_sign
- Approve and reject
aptos_signTransaction
- Approve and reject
aptos_sendTransaction
connect test simple :wallectconnect-cc-example, https://wallectconnect-cc-example.vercel.app
Android releases are hosted on GitHub packages, you need to add GitHub access token to install it. Please checkout this installation guide.
dependencies {
implementation "org.comingchat:wallet-connect-v1:$Tag"
}
replace the
Tag
in the code with latest
parse session from scanned QR code:
val peerMeta = WCPeerMeta(name = "App name", url = "https://website.com")
val string = "wc:..."
val session = WCSession.from(string) ?: throw InvalidSessionError // invalid session
// handle session
wcClient.connect(wcSession, peerMeta)
configure and handle incoming message:
val wcClient = WCClient(GsonBuilder(), okHttpClient)
wcClient.onDisconnect = { _, _ ->
onDisconnect()
}
wcClient.onSessionRequest = { _, peer ->
// ask for user consent
}
wcClient.onDisconnect = { _, _ ->
// handle disconnect
}
wcClient.onFailure = { t ->
// handle failure
}
wcClient.onGetAccounts = { id ->
// handle get_accounts
}
wcClient.onEthSign = { id, message ->
// handle eth_sign, personal_sign, eth_signTypedData
}
wcClient.onEthSignTransaction = { id, transaction ->
// handle eth_signTransaction
}
wcClient.onEthSendTransaction = { id, transaction ->
// handle eth_sendTransaction
}
wcClient.onSignTransaction = { id, transaction ->
// handle bnb_sign
}
wcClient.onWalletChangeNetwork = { id, chainId->
// handle wallet_switchEthereumChain
}
approve session
wcClient.approveSession(listOf(address), chainId)
approve request
wcClient.approveRequest(id, signResult) // hex formatted sign
disconnect
if (wcClient.session != null) {
wcClient.killSession()
} else {
wcClient.disconnect()
}
keep models for gson
,proguard-rules.pro
WalletConnect is available under the MIT license. See the LICENSE file for more info.