// Check available balance first
val balance = withContext(Dispatchers.IO) {
sdk.getBalance(tokenAddress = tokenAddress)
}
val shielded = balance.shieldedBalance.toBigInteger()
val unshieldAmount = amount.toBigInteger()
require(unshieldAmount <= shielded) { "Insufficient shielded balance" }
val result = withContext(Dispatchers.IO) {
sdk.unshield(
tokenAddress = tokenAddress,
amount = amount,
recipient = recipientAddress
)
}