/kSolana

Solana Client Library written in Kotlin using coroutines

Primary LanguageKotlinMIT LicenseMIT

kSolana

Solana blockchain client, ported from SolanaJ to Kotlin using coroutines. kSolana is an API for integrating with Solana blockchain using the Solana RPC API

Requirements

  • Java 11+
  • Android Api 26+

Dependencies

How to

  1. Add it in your root build.gradle at the end of repositories:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency
dependencies {
    implementation 'com.github.guness:kSolana:-SNAPSHOT' 
}

Example

Transfer lamports
val api = RpcApi(RpcClient(Cluster.TESTNET))
val fromPublicKey = PublicKey("QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo")
val toPublicKey = PublicKey("GrDMoeqMLFjeXQ24H56S1RLgT4R76jsuWCd6SvXyGPQ5")
val lamports = 3000L

val signer = Account("4Z7cXSyeFR8wNGMVXUE1TwtKn5D5Vu7FzEv69dokLv7KrQk7h6pu4LF8ZRR9yQBhc7uSM6RTTZtU1fmaxiNrxXrs")

val transaction = Transaction()
transaction.addInstruction(transfer(fromPublicKey, toPublicKey, lamports))

val signature = api.sendTransaction(transaction, signer)
Get balance
val api = RpcApi(RpcClient(Cluster.TESTNET))

val balance = api.getBalance(PublicKey("QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo"))