Scv
Provides a range of methods to help you build and parse SCValXdr more conveniently.
This utility class offers factory methods for creating Soroban Contract Values (SCVal) from Kotlin native types and converting them back. All methods are optimized for production use with proper validation and error handling.
Usage Example
// Create SCVal from primitive types
val int32Val = Scv.toInt32(42)
val stringVal = Scv.toString("hello")
val boolVal = Scv.toBoolean(true)
// Create SCVal from collections
val vecVal = Scv.toVec(listOf(int32Val, stringVal))
val mapVal = Scv.toMap(linkedMapOf(
Scv.toSymbol("key") to Scv.toInt64(100L)
))
// Convert back to Kotlin types
val intValue = Scv.fromInt32(int32Val) // 42
val strValue = Scv.fromString(stringVal) // "hello"Functions
Convert from SCValXdr with the type of SCValTypeXdr.SCV_ADDRESS to SCAddressXdr.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_BOOL to Boolean.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_CONTRACT_INSTANCE to SCContractInstanceXdr.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_DURATION to ULong.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_ERROR to SCErrorXdr.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_I128 to BigInteger.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_I256 to BigInteger.
Parse from SCValXdr with the type of SCValTypeXdr.SCV_LEDGER_KEY_CONTRACT_INSTANCE. This function validates the type and returns Unit if successful.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_LEDGER_KEY_NONCE to SCNonceKeyXdr.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_MAP to LinkedHashMap.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_STRING to String.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_SYMBOL to String.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_TIMEPOINT to ULong.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_U128 to BigInteger.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_U256 to BigInteger.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_U32 to UInt.
Convert from SCValXdr with the type of SCValTypeXdr.SCV_U64 to ULong.
Parse from SCValXdr with the type of SCValTypeXdr.SCV_VOID. This function validates the type and returns Unit if successful.
Build a SCValXdr with the type of SCValTypeXdr.SCV_ADDRESS.
Build a SCValXdr with the type of SCValTypeXdr.SCV_CONTRACT_INSTANCE.
Build a SCValXdr with the type of SCValTypeXdr.SCV_DURATION.
Build a SCValXdr with the type of SCValTypeXdr.SCV_ERROR.
Build a SCValXdr with the type of SCValTypeXdr.SCV_I128.
Build a SCValXdr with the type of SCValTypeXdr.SCV_I256.
Build a SCValXdr with the type of SCValTypeXdr.SCV_LEDGER_KEY_CONTRACT_INSTANCE.
Build a SCValXdr with the type of SCValTypeXdr.SCV_LEDGER_KEY_NONCE.
Build a SCValXdr with the type of SCValTypeXdr.SCV_MAP.
Build a SCValXdr with the type of SCValTypeXdr.SCV_TIMEPOINT.
Build a SCValXdr with the type of SCValTypeXdr.SCV_U128.
Build a SCValXdr with the type of SCValTypeXdr.SCV_U256.
Build a SCValXdr with the type of SCValTypeXdr.SCV_VOID.