Tapyrus Wallet Android is a Kotlin library for interacting with the Tapyrus blockchain on Android devices. This library provides a comprehensive set of tools for creating and managing Tapyrus wallets, handling transactions, and interacting with the Tapyrus network.
- Create and manage HD wallets for Tapyrus
- Generate and manage wallet addresses
- View wallet balances (TPC and colored coins)
- Sign and verify messages
- Create and broadcast transactions
- Synchronize wallet with the blockchain
- Support for colored coins
- Pay-to-Contract Protocol support
- Android SDK 24 or higher
- Kotlin 2.1.10 or higher
- JDK 17 or higher
Add the GitHub Packages repository to your project's settings.gradle.kts file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/chaintope/rust-tapyrus-wallet-ffi")
credentials {
username = providers.gradleProperty("gpr.user").getOrElse("")
password = providers.gradleProperty("gpr.key").getOrElse("")
}
}
}
}GitHub Packages requires authentication even for public packages. Add your GitHub username and a Personal Access Token (PAT) with the read:packages scope to your Gradle properties.
You can add these credentials in one of two ways:
# In project's gradle.properties
gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_TOKEN# In ~/.gradle/gradle.properties
gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_TOKENAdd the Tapyrus Wallet Android dependency to your app's build.gradle.kts file:
dependencies {
implementation("com.chaintope.tapyrus.wallet:tapyrus-wallet-android:0.1.5")
// Other dependencies...
}// Create a wallet configuration
val config = Config(
networkMode = Network.PROD, // or Network.DEV for development
networkId = 1939510133u, // Tapyrus network ID
genesisHash = "...", // Genesis block hash
esploraUrl = "https://esplora.example.com", // Esplora API URL
dbFilePath = "path/to/wallet.db" // Path to store wallet database
)// Generate a new master key
val masterKey = generateMasterKey(Network.PROD)
// Create a wallet with the master key
val config = Config(
networkMode = Network.PROD,
networkId = 1939510133u,
genesisHash = "...",
esploraUrl = "https://esplora.example.com",
masterKey = masterKey,
dbFilePath = "path/to/wallet.db"
)
// Initialize the wallet
val wallet = HdWallet(config)// Sync the wallet with the blockchain
wallet.sync()
// For a full sync from the genesis block
wallet.fullSync()// Generate a new address for TPC
val result = wallet.getNewAddress()
val address = result.address
val publicKey = result.publicKey
// Generate a new address for a colored coin
val colorId = "c3ec2fd806701a3f55808cbec3922c38dafaa3070c48c803e9043ee3642c660b46"
val coloredResult = wallet.getNewAddress(colorId)// Get TPC balance
val tpcBalance = wallet.balance()
// Get colored coin balance
val colorId = "c3ec2fd806701a3f55808cbec3922c38dafaa3070c48c803e9043ee3642c660b46"
val coloredBalance = wallet.balance(colorId)// Create transfer parameters
val params = listOf(
TransferParams(
amount = 1000000u,
toAddress = "recipient-address"
)
)
// Execute the transfer
val txid = wallet.transfer(params, emptyList())// Sign a message
val signature = wallet.signMessage(publicKey, "Hello, Tapyrus!")
// Verify a signature
val isValid = wallet.verifySign(publicKey, "Hello, Tapyrus!", signature)An example Android application demonstrating the usage of this library is available in the example directory. The example includes a Docker Compose setup for running a local Tapyrus node and Electrs server for testing.
For more detailed documentation, please refer to the API documentation ZIP.
To release a new version, follow these steps:
- Update the version in
tapyrus-wallet-ffi/Cargo.toml - Commit and push the changes
git add . git commit -m "Bump version to X.Y.Z" git push
- Create and push a tag (CI will automatically update Android/C# versions)
git tag vX.Y.Z git push origin vX.Y.Z
The CI workflows will:
- Verify that the tag version matches
Cargo.toml - Automatically update
gradle.properties(Android) and.csproj(C#) with the tag version - Build and publish packages to GitHub Packages / GitHub Releases
- Mark releases with
-in the version (e.g.,v0.1.3-beta.1) as prerelease