Skip to main content

Get Started with the Altude Android SDK for Solana

The Altude Android SDK enables you to build powerful Solana blockchain applications directly in your Android app using Kotlin. With this SDK, you can create and manage Solana accounts, check balances, transfer tokens (including KIN, USDC, and more), and interact with the Solana blockchain—all from your mobile device. Follow the steps below to integrate the Altude SDK into your Android project and start building decentralized apps on Solana.

Installation


title: “Install” # This controls sidebar name

In your root build.gradle or settings.gradle, make sure you’ve included JitPack:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
And add the dependency, normally in the module-level build.gradle:
dependencies {
    implementation 'altude:gasstation:@lastest'
}

Instantiate the Altude Client

The Altude Client gives you access to all the methods you need to work with Solana via Altude. We recommend starting with Devnet before moving on to Mainnet. The Altude SDK uses Kotlin suspend functions to perform asynchronous network calls. We recommend calling these from within a CoroutineScope as needed.
import com.altude.gasstation

Altude.setApiKey(context, "myAPIKey")
Altude.savePrivateKey(accountPrivateKey)
Don’t have an App Index? Join our Discord and we’ll get you started. While you’re waiting for confirmation of your App Index, use 1 on devnet so you can get started.

Create Account

You can create accounts randomly or from existing mnemonics or secret keys. Below, we’ll make a keypair and use that for creating an account on the blockchain.
val keypair = KeyPair.generate()
val options = CreateAccountOption(
	tokens = listOf(Token.USDC.mint()),
	commitment = Commitment.finalized,
)
val result = Altude.createAccount(options)

Close Account

It’s good practice to close unneeded accounts. You can only close accounts that you have created and are currently empty.
val options = CloseAccountOption(
	account = "",   //optional
	tokens  = listOf(Token.USDC.mint())
)
val result = Altude.closeAccount(options)

Check Balance

Check a user balance by passing in the public key of the account you want to check. The response object includes your total balance as well as detailing all of the Mints and Tokens held by that Public Key.
val option = GetBalanceOption(
	token = Token.USDC.mint()
)
 val balance = Altude.getBalance(option)?.amount

Transfer a Token

Transfer a token from a Keypair to any Public Key.
val options = TransferOptions(
	account = "", //optional
	toAddress = "EykLriS4Z34YSgyPdTeF6DHHiq7rvTBaG2ipog4V2teq",
	amount = 0.00001
)

val result = Altude.send(options)
Altude will transfer the kin token by default unless specified otherwise. To send a different token make sure to include the mint parameter like below
 val options = TransferOptions(
	account = "", //optional
	toAddress = "EykLriS4Z34YSgyPdTeF6DHHiq7rvTBaG2ipog4V2teq",
	amount = 0.00001,
	token = Token.USDC.mint(), // Token (mint) address for USDC
	commitment = Commitment.finalized // 
)
val result = Altude.send(options)

Get Account History

Get the full transaction history of any account by passing in the account’s Public Key.
val accountHistory = Altude.getHistory(owner.publicKey)

Get Account Info

Easily get the main info of any account by passing in the account’s Public Key.
val accountInfo = Altude.getAccountInfo(owner.publicKey)

Demos and Starter Kits

Created to help get you up and running as quickly as possible, these projects can be a great reference point when you get stuck or even a starter for your own project. Happy coding!
Coming soon!
I