Android

Integrate Pallet wallet through Deeplink.

<intent-filter >
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "example://gizmos” -->
    <data android:scheme="palletdapp"
        android:host="wc" />
</intent-filter>

Step 2: Add Gradle Dependency

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

Add SDK dependencies from and find the last version.

dependencies {
 implementation 'com.github.bitbeen:PalletConnectKotlin:1.0.0'
}

Step 3: Integration in APP

1. Init WalletConnect

val connection = PalletConnectApi(object :palletConnectDelegate{
        override fun didConnect(chainId: Int?, accounts: String?) {
            TODO("Connect success, return chainId and wallet address")
        }

        override fun didDisconnect() {
            TODO("Disconnect")
        }

        override fun failedToConnect() {
            TODO("Connect fail")
        }

    })

2. Connect wallet via WalletConnect

connection.connect(
        context = requireContext(),
        dappName = "Example App",
        dappDescription = "palletconnect_android_example",
        dappUrl = "https://example.com",
        icons = listOf("Image used to showcase the dapp on the pallet App"),
        callbackUrl = "gamedapp://xxx", // Set to return the deeplink of the current App
)

3. Personal Sign

connection.personalSign(
            requireContext(),
            message = "0xff",
            account = "Wallet Address"
        ) {resp ->
            // The callback method is located in the child thread, 
            // be sure to switch to the UI thread for UI display
            uiScope.launch {    
                binding.txRespData.text = it.result.toString()
            }
        }

4. Typed Sign

connection.ethSignTypedData(
    requireContext(),
    message = "{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"wallet\",\"type\":\"address\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person\"},{\"name\":\"contents\",\"type\":\"string\"}]},\"primaryType\":\"Mail\",\"domain\":{\"name\":\"Ether Mail\",\"version\":\"1\",\"chainId\":1,\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\"},\"message\":{\"from\":{\"name\":\"Cow\",\"wallet\":\"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\"},\"to\":{\"name\":\"Bob\",\"wallet\":\"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB\"},\"contents\":\"Hello, Bob!\"}}",
    account = it
){
        uiScope.launch {
            binding.txRespData.text = it.result.toString()
        }
 }

5. Send Transaction

connection.ethSendTransaction(
        requireContext(),
        Transaction(
            from = binding.txAddress.text.toString(),
            to = binding.txAddress.text.toString(),
            nonce = null,
            gasPrice = null,
            gasLimit = null,
            value = "0xff",
            data = "0x",
        )
    ) {
        uiScope.launch {
            binding.txRespData.text = it.result.toString()
        }
    }

Last updated