Skip to content

Bitcoin-com/concordium-id-kotlin-sdk

Β 
Β 

Repository files navigation

Concordium IDApp SDK for Android

License

Build secure and user-friendly blockchain applications with Concordium's official Android SDK

The Concordium IDApp SDK enables Android developers to seamlessly integrate Concordium blockchain functionality into their applications. This SDK provides a robust set of tools for account management, transaction signing, and secure interactions with the Concordium blockchain.

πŸš€ Features

  • πŸ” Secure account management and key generation
  • πŸ“ Transaction signing and submission
  • πŸ”— WalletConnect integration for ID App interactions
  • πŸ“± Ready-to-use UI components

πŸ“¦ Package Information

πŸ”§ Installation

Option 1: Git Submodule (Recommended)

This method is ideal for developers who want to use the SDK directly and potentially contribute back to the project.

git submodule add https://github.com/Concordium/concordium-id-kotlin-sdk.git libs/concordium-id-kotlin-sdk
git submodule update --init --recursive
  1. Include the module in your settings.gradle.kts (or settings.gradle):
include(":libs:concordium-idapp-sdk")
  1. Add a project dependency in your app module's build.gradle.kts:
dependencies {
    implementation(project(":libs:concordium-idapp-sdk"))
    implementation("com.concordium.sdk:concordium-android-sdk:11.1.0")
}

Option 2: Maven Repository (Yet to be Live)

If you prefer using dependency management:

dependencies {
    implementation("com.concoridum.sdk:concordium-idapp-sdk:x.y.z") // Replace with latest version
}

πŸ’‘ Tips:

  • Run Gradle sync after adding the dependency
  • Check releases page for the latest version

πŸš€ Getting Started

Initialization

Call the initializer early in your app (for example, in Application.onCreate):

import com.concordium.idapp.sdk.api.ConcordiumIDAppSDK

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        ConcordiumIDAppSDK.initialize(this, enableDebugLog = false)
    }
}

πŸ“š API Reference

The SDK provides a clean and intuitive API through three main components:

1. πŸ›  ConcordiumIDAppSDK

Core functionality for blockchain interactions:

  • initialize(context: Context, enableDebugLog: Boolean = false)
  • signAndSubmit(seedPhrase: String, expiry: Long, unsignedCdiStr: String, accountIndex: Int = 0, network: Network = Network.MAINNET): String
  • generateAccountWithSeedPhrase(seed: String, network: Network, accountIndex: Int = 0): CCDAccountKeyPair
  • clear()

2. πŸ–Ό ConcordiumIDAppPopup

UI components and flows for user interactions:

  • invokeIdAppDeepLinkPopup: Launch WalletConnect flows
  • invokeIdAppActionsPopup: Present account creation/recovery options
  • closePopup: Dismiss active popups

3. πŸ”‘ CCDAccountKeyPair

Essential account data model:

  • publicKey: Account's public verification key
  • signingKey: Account's signing key

πŸ’‘ Code Examples

Here are some common use cases to help you get started:

1) Sign and submit a credential deployment transaction

Make sure unsignedCdiStr contains a valid JSON string matching UnsignedCredentialDeploymentInfo.

import com.concordium.idapp.sdk.api.ConcordiumIDAppSDK
import com.concordium.sdk.crypto.wallet.Network

fun submit(seedPhrase: String, unsignedCdiJson: String) {
    val expiryEpochSec = 1710000000L // choose appropriate expiry
    val txHash = ConcordiumIDAppSDK.signAndSubmit(
        seedPhrase = seedPhrase,
        expiry = expiryEpochSec,
        unsignedCdiStr = unsignedCdiJson,
        accountIndex = 0,
        network = Network.MAINNET,
    )
    println("Transaction hash: $txHash")
}

2) Launching ID App deep-link flow

import com.concordium.idapp.sdk.api.ConcordiumIDAppPopup

val walletConnectUri = "wc:...@2?relay-protocol=...&symKey=..."
ConcordiumIDAppPopup.invokeIdAppDeepLinkPopup(walletConnectUri)

4) Present create/recover actions popup

ConcordiumIDAppPopup.invokeIdAppActionsPopup(
    walletConnectSessionTopic = "abcd1234...",
    onCreateAccount = { /* handle create */ },
    onRecoverAccount = { /* handle recover */ },
)

3) Derive account keys from a seed phrase

import com.concordium.idapp.sdk.api.ConcordiumIDAppSDK
import com.concordium.idapp.sdk.api.model.CCDAccountKeyPair
import com.concordium.sdk.crypto.wallet.Network

fun showKeys(seed: String) {
    val keys: CCDAccountKeyPair = ConcordiumIDAppSDK.generateAccountWithSeedPhrase(
        seed = seed,
        network = Network.MAINNET,
        accountIndex = 0,
    )

    println("publicKey=${keys.publicKey}")
    println("signingKey=${keys.signingKey}")
}

Cleanup

When you're done using the SDK, make sure to clean up resources:

ConcordiumIDAppSDK.clear()

🌐 Network Configuration

The SDK seamlessly integrates with both production and testing environments:

Mainnet

  • URL: https://grpc.mainnet.concordium.software
  • Use Case: Production deployments
  • Default Port: 20000

Testnet

  • URL: grpc.testnet.concordium.com
  • Use Case: Development and testing
  • Default Port: 20000

πŸ“¦ Dependencies

The SDK is built with industry-standard technologies:

  • Jetpack Compose for UI components
  • ZXing for QR code generation
  • Concordium Android SDK for blockchain interactions

πŸ“‹ Release Guidelines

Creating a New Release

Follow these steps to publish a new version of the SDK:

  1. Ensure you are on the main branch and it is up to date:

    git checkout main
    git pull origin main
  2. Make sure all tests pass and the build is successful:

    ./gradlew clean build test
  3. Update the version number in concordium-idapp-sdk/build.gradle.kts:

    • Follow semantic versioning (MAJOR.MINOR.PATCH)
    • Example: version = "1.0.0"
  4. Commit the version change:

    git add concordium-idapp-sdk/build.gradle.kts
    git commit -m "Bump version to x.y.z"
  5. Create and push a new tag:

    git tag -a vx.y.z -m "Release version x.y.z"
    git push origin main --tags
  6. Create a release on GitHub:

    • Go to the repository's Releases page
    • Click "Create a new release"
    • Select the tag you just created
    • Title: "Release vx.y.z"
    • Add release notes describing the changes
    • Attach any relevant binaries or documentation

Notes:

  • Replace x.y.z with the actual version number
  • Always create releases from the main branch
  • Ensure all changes are properly documented
  • Follow semantic versioning guidelines:
    • MAJOR: Breaking changes
    • MINOR: New features (backwards compatible)
    • PATCH: Bug fixes (backwards compatible)

🀝 Contributing

We welcome contributions from the community! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to your branch
  5. Open a Pull Request

Please ensure your code follows our coding standards and includes appropriate tests.

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ’¬ Support

Need help? We're here for you!

⚠️ Important Notes

  • Always call ConcordiumIDAppSDK.initialize(context) before any other function.
  • signAndSubmit parses the unsignedCdiStr JSON; ensure it is valid. The function will throw if parsing fails.
  • Network calls use the Concordium Java/Kotlin client; ensure correct network selection (Network.MAINNET vs Network.TESTNET) and permissions.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%