WalletConnect Kit is the Swiss Army toolkit for WalletConnect!

Overview

WalletConnectKit

Release

WalletConnectKit is the Swiss Army toolkit for WalletConnect! It will allow you to connect your DApp with an Ethereum Wallet in a few minutes and start performing transactions right away.

Note: Currently, we only support the v1 protocol of WalletConnect, since it is the protocol most implemented by Wallets. As soon as Wallets implement the v2 protocol and theWalletConnect library for Kotlin is stable, we will support the v2 protocol.


InstallationSetupConnect ButtonTransactionsAdvanced


Demo

Installation

    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }

    dependencies {
        implementation 'dev.pinkroom:walletconnectkit:<last_version>'
    }

Setup

First, you need to create a config:

val config = WalletConnectKitConfig(
    context = this,
    bridgeUrl = "wss://bridge.aktionariat.com:8887",
    appUrl = "walletconnectkit.com",
    appName = "WalletConnectKit",
    appDescription = "WalletConnectKit is the Swiss Army toolkit for WalletConnect!"
)

Note: The bridge url provided above is a deployed version of this repo by its owner. Feel free to use it or use your own bridge server.

Then, build the WalletConnectKit instance:

val walletConnectKit = WalletConnectKit.Builder(config).build()

And you are ready to go! 🚀

Connect Button

Add the WalletConnectButton to your layout:

<dev.pinkroom.walletconnectkit.WalletConnectButton
    android:id="@+id/walletConnectButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Start the button with the WalletConnectKit instance created before. When the account is successfully connected you will receive the account address.

walletConnectButton.start(walletConnectKit) { address ->
    println("You are connected with account: $address")
}

Note: WalletConnectButton is an ImageButton with a default theme that can be overridden by you!

If you want to be informed about the status of the WalletConnect session, you can set a Session.Callback before calling the start method.

class MyActivity : AppCompatActivity(), Session.Callback {

    override fun onMethodCall(call: Session.MethodCall) {
        // Handle onMethodCall
    }

    override fun onStatus(status: Session.Status) {
        // Handle session status
    }
}
walletConnectButton.sessionCallback = this

Transactions

In order to perform a transaction you just need to call the performTransaction method. This method is a suspend function so, you need to call it inside a coroutine.

lifecycleScope.launch {
    runCatching { walletConnectKit.performTransaction(toAddress, value) }
        .onSuccess { /* Handle onSuccess */ }
        .onFailure { /* Handle onFailure */ }
}

Note: If you want to perform a transaction through a smart contract function, you need to pass the encoded function data of the smart contract to the data parameter of the performTransaction function.

Advanced

If you don't want to use the WalletConnectKitButton and want to create your own implementation, you can still use the WalletConnectKit to manage the connection between your DApp and Wallet.

Below are the most relevant methods provided by the WalletConnectKit that you need to care about:

Method Description
createSession(callback: Session.Callback) Creates a session and stores it locally. After calling this method you should receive a `Session.Status.Connected` in the passed callback. This is where you should call the `requestHandshake` method (see below).
removeSession() Removes the current session and cleans everything related to it.
loadSession(callback: Session.Callback) Loads the session that is stored locally.
isSessionStored A flag that tells you if there is any session stored locally.
session Returns the current session or null otherwise.
address Returns the approved account address or null otherwise.
requestHandshake() Starts an intent that performs the handshake between your DApp and a Wallet.
openWallet() Starts an intent that opens a Wallet.

License

Copyright 2021 Pink Room, Lda

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Moshi IllegalArgumentException

    Moshi IllegalArgumentException

    When I implement your code try to run I got this issue,

    java.lang.IllegalArgumentException: Cannot serialize Kotlin type org.walletconnect.impls.MoshiPayloadAdapter$EncryptedPayload. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapterFactory from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.

    help wanted 
    opened by jaydipumaretiya 5
  • Sign transaction without call

    Sign transaction without call

    Is there a way to only sign transaction without performing?

    Снимок экрана 2022-02-22 в 07 44 15

    I want to get raw signed message from this params

    P.s. SignedTransaction is a value class with single String parameter in constructor

    enhancement 🚀 
    opened by y9san9 4
  • Possibility to connect wallet without opening third party apps

    Possibility to connect wallet without opening third party apps

    Is there any possibility to connect wallet without opening third party apps like metamask, trustwallet. How can we achieve functionality which is implemented inside metamask, trustwallet kind of apps? Maybe opening webview inside my application. Can you suggest any direction where I can look into?

    help wanted 
    opened by zharassamat 2
  • Add FLAG_ACTIVITY_NEW_TASK for wallet intent

    Add FLAG_ACTIVITY_NEW_TASK for wallet intent

    Good morning,

    I've been using your awesome lib to integrate it in a service which only has an ApplicationContext provided by Hilt. As this service will be used by a JetpackCompose app, I couldn't use the button provided by walletconnectkit. This small change was the only thing that prevented me to use the library, as android would not allow starting an activity outside of an activity context without FLAG_ACTIVITY_NEW_TASK being specified.

    opened by Crysis21 2
  • Walletconnectkit pulling wrong/old web3j:utils dependency

    Walletconnectkit pulling wrong/old web3j:utils dependency

    I was scratching my head because of the following issue when using walletconnectkit while also using the standard web3j:core dependency in one project:

    java.lang.NoSuchMethodError: No static method isBlank(Ljava/lang/String;)Z in class Lorg/web3j/utils/Strings; or its super classes (declaration of 'org.web3j.utils.Strings' at org.web3j.ens.EnsResolver.resolve(EnsResolver.java:152)

    Running ./gradlew app:dependencies and also the walletconnectkit gradle shows that you are pulling web3j:utils:5.0.0 which imho is incorrect as the current version is 4.9.4. I honestly dont know why there is even a maven upload with a 5.0.0 tag. The 5.0.0 build is indeed missing Strings.isBlank.

    So I think walletconnectkit should "downgrade" the web3j:utils version to the current 4.9.4.

    opened by RWolfing 0
  • not display SendTransaction

    not display SendTransaction

    I do run performTransaction but the result i get is the app just opens up the metaMask and doesn't do anything else? Who has encountered this problem and fixed it then please give me the solution. Thank

    opened by dophunhan 2
  • Getting issues in *performTransaction*

    Getting issues in *performTransaction*

    Hello, We have implemented Wallet Connect in our Android Mobile App. But we are facing issue while performing transaction and sometime while connect as once i connect my app with trust wallet app it works then I make request to perform transaction popup appears but taking more time to load and sometime when I hit for connect popup appears for transaction. Can you please help me for this.

    opened by Jatinharish 1
  • WalletConnect dependency not working

    WalletConnect dependency not working

    I want to perform a transaction using metamask. Connect button is working, but when I try to perform a transaction, it redirected to metamask, but nothing happens. No dialog is showing.

    Has anyone found any solution also when I install this dependency on another project and try to run the project it's throwing an error. Can anybody help me image

    opened by Mukesh6201 1
Releases(0.3.2)
Owner
Pink Room
Mobile app experts.
Pink Room
A toolkit for ebooks, audiobooks and comics written in Kotlin

Readium Kotlin Toolkit Readium Mobile is a toolkit for ebooks, audiobooks and comics written in Swift & Kotlin. This toolkit is a modular project, whi

Readium 74 Jan 3, 2023
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Ionic Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a sin

Ionic 48.4k Jan 3, 2023
A Minecraft Kit API written in Kotlin

hglabor-kits Dependency The library is available on Maven Central, add the following dependencies: implementation("net.axay:hglabor-kits:$version") hg

Jakob K 8 Apr 8, 2022
Text Recognizer App Using the ML Kit

Features Detects text in images Using the ML Kit Text Recognition API Uses the CameraX to show a viewfinder and display the camera preview Provides a

krishna chaitanya 9 Nov 5, 2022
Native android application that scans for text in images. Uses ML kit under the hood.

Scannerate - Ad free Text Recognition Android application built using Kotlin to extract text from images. Uses Google's ML kit library under the hood.

null 24 Dec 1, 2022
SmartLens uses Google's ML Kit for Barcode scanning, Face recognition, Text recognition, and Image labeling.

SmartLens SmartLens uses Google's ML Kit for Barcode scanning, Face recognition, Text recognition, and Image labeling. ?? Screen Shots ?? Features It

Prince Fahad 2 Sep 14, 2022
Face Detector Using Firebase ML Kit

Face Detector (Using Firebase ML Kit) Detects Facial Expression ------> Overlays

Sachin Kumar 1 Jan 4, 2022
This application uses Google Play Services Vision library to scan barcodes. It uses Google's on device ML kit to scan for barcodes.

Barcode-Scanner This application showcases use of Google Play Services Vision library It uses Google's on device machine learning kit to scan for barc

Soumik 2 Apr 28, 2022
Lightning Dev Kit Android Demo Wallet

uMlando-wallet Lightning Dev Kit Android Demo Wallet This project uses a .aar package for the Android platforms that provide language bindings for the

Conor Okus 6 Dec 23, 2022
Mole Analysis Use Case for HMS ML Kit Custom Model

Mole Analysis Mole Analysis Use Case for HMS ML Kit Custom Model Introduction What is Melanoma? Melanoma is the most serious among skin cancers becaus

null 15 Aug 23, 2022
A powerful library for easy implementation of HMS Location Kit.

AdvancedLocation A powerful library for easy implementation of HMS Location Kit. ?? Request location with couple lines of code (no more boilerplate) C

null 2 Aug 4, 2022
Android barcode scanner with ML-Kit vision api

MLBarcodeScanner A demo project to show how to implement barcode scanner using Google ML-Kit Vision api Supported barcode types 2D formats: QR Code, A

Mahdi Javaheri 5 Dec 26, 2022
🔪Swiss-army knife for Android testing and development 🔪 ⛺

ADB Enhanced ADB-Enhanced is a Swiss-army knife for Android testing and development. A command-line interface to trigger various scenarios like screen

Ashish Bhatia 938 Dec 20, 2022
Swiss army knife for identifying and fingerprinting Android devices.

fingerprint android Lightweight library for device identification and fingerprinting. Fully written in Kotlin. 100% Crash-free. Creates a device ident

FingerprintJS 357 Jan 7, 2023
Frogo Android UI Kit - Frogo UI Design Kit Guideline

About This Project Follow-up project from frogo-ui-kit UI Kit for helping you in apps development Migrate from frogo-ui-kit Just renaming package com.

Frogobox 6 Nov 25, 2022
WalletConnect Kotlin SDK v2

WalletConnect V2 - Kotlin Kotlin implementation of WalletConnect v2 protocol for Android applications. Requirements Android min SDK 21 Java 11 Install

WalletConnect Labs 11 Dec 22, 2021
Kotlin implementation of WalletConnect v2 protocol for Android applications

WalletConnect V2 - Kotlin Kotlin implementation of WalletConnect v2 protocol for

WalletConnect 92 Jan 6, 2023
An enhanced version of the Volley Networking Toolkit for Android

enhanced-volley An Enhanced version of the Volley Networking Tookit for Android License Copyright (C) 2011 The Android Open Source Project Copyright (

Vinay Shenoy 150 Nov 15, 2022
Forget about bunch of XML files for maintaining UIs. Jetpack Compose is Android’s modern toolkit for building native UI. Here is a small example to get started.

Jetpack Compose Sample Description This repository is to get started with new Jetpack Compose Toolkit for Android. By using Jetpack Compose you no nee

Simform Solutions 39 Nov 10, 2022
Kotlin multiplatform benchmarking toolkit

NOTE: Starting from version 0.3.0 of the library: The library runtime is published to Maven Central and no longer published to Bintray. The Gradle plu

Kotlin 310 Jan 2, 2023