scValToNative

fun scValToNative(scVal: SCValXdr, typeDef: SCSpecTypeDefXdr?): Any?

Converts an SCValXdr to a native Kotlin value based on the type specification.

This is the core conversion method that handles all type mappings from Stellar XDR values to Kotlin native types. It's the inverse operation of nativeToXdrSCVal.

Type Mappings

  • Void → null

  • Bool → Boolean

  • U32, I32 → Int/UInt

  • U64, I64 → Long/ULong

  • U128, I128, U256, I256 → BigInteger

  • String, Symbol → String

  • Bytes → ByteArray

  • Address → String (StrKey-encoded)

  • Timepoint, Duration → ULong

  • Vec → List

  • Map → List>

  • Tuple → List

  • UDT (struct) → Map or List (depending on field names)

  • UDT (union) → NativeUnionVal

  • UDT (enum) → UInt

  • Error → SCErrorXdr

  • ContractInstance → SCContractInstanceXdr

Return

The converted native Kotlin value

Parameters

scVal

The XDR value to convert

typeDef

The type specification (nullable for direct type inference)

Throws

for invalid types or conversion failures