在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):trustwallet/wallet-connect-kotlin开源软件地址(OpenSource Url):https://github.com/trustwallet/wallet-connect-kotlin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):WalletConnectWalletConnect Kotlin SDK, implements 1.0.0 websocket based protocol. DemoFeatures
InstallationAdd it in your root build.gradle at the end of repositories: allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
} Add the following line to your app's build.gradle: dependencies {
implementation "com.github.TrustWallet:wallet-connect-kotlin:$wc_version"
} Usageparse 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
} 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()
} LicenseWalletConnect is available under the MIT license. See the LICENSE file for more info. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论