Functions
The following functions are available globally.
-
Encodes data to base32 string using the standard alphabet.
Uses the standard base32 alphabet (A-Z, 2-7) as defined in RFC 4648.
Example:
let data = Data([1, 2, 3, 4, 5]) let encoded = base32Encode(data)Declaration
Swift
public func base32Encode(_ data: Data) -> StringParameters
dataData to encode
Return Value
Base32-encoded string
-
Encodes data to base32 string using the extended hex alphabet.
Uses the extended hex alphabet (0-9, A-V) as defined in RFC 4648.
Declaration
Swift
public func base32HexEncode(_ data: Data) -> StringParameters
dataData to encode
Return Value
Base32hex-encoded string
-
Decodes a base32 string to data using the standard alphabet.
Example:
if let decoded = base32DecodeToData("AEBAGBA") { // Use decoded data }Declaration
Swift
public func base32DecodeToData(_ string: String) -> Data?Parameters
stringBase32-encoded string
Return Value
Decoded data, or nil if the string is invalid
-
Decodes a base32hex string to data using the extended hex alphabet.
Declaration
Swift
public func base32HexDecodeToData(_ string: String) -> Data?Parameters
stringBase32hex-encoded string
Return Value
Decoded data, or nil if the string is invalid
-
Encodes a byte array to base32 string using the standard alphabet.
Declaration
Swift
public func base32Encode(_ array: [UInt8]) -> StringParameters
arrayByte array to encode
Return Value
Base32-encoded string
-
Encodes a byte array to base32 string using the extended hex alphabet.
Declaration
Swift
public func base32HexEncode(_ array: [UInt8]) -> StringParameters
arrayByte array to encode
Return Value
Base32hex-encoded string
-
Decodes a base32 string to a byte array using the standard alphabet.
Declaration
Swift
public func base32Decode(_ string: String) -> [UInt8]?Parameters
stringBase32-encoded string
Return Value
Decoded byte array, or nil if the string is invalid
-
Decodes a base32hex string to a byte array using the extended hex alphabet.
Declaration
Swift
public func base32HexDecode(_ string: String) -> [UInt8]?Parameters
stringBase32hex-encoded string
Return Value
Decoded byte array, or nil if the string is invalid
-
Returns the absolute value of the given number.
Parameters
xa big double
-
round to largest BInt value not greater than base
-
round to smallest BInt value not less than base
-
Returns a BDouble number raised to a given power.
-
Orders two
SCValXDRvalues the way the Soroban host orders ScMap keys.The host stores and validates ScMap keys in this order and rejects a contract argument map whose keys are out of order with
InvalidInput.Ordering (rs-soroban-env
Compare<ScVal>):- Values of different types compare by their
SCValTypediscriminant. I32,I64andLedgerKeyNoncecompare numerically as signed values;I128andI256compare the signed high part first, then the unsigned lower parts.Veccompares element-wise (recursively); the shorter vec sorts first on a prefix tie.Mapcompares entry-wise (key, then value, recursively); the map with fewer entries sorts first on a prefix tie.Bytes,String,Symbol, andExecutableTagcompare by content, byte for byte (unsigned); the shorter value sorts first on a prefix tie.ContractInstancecompares by executable (type, then payload; an external reference by owner, then tag content), then by storage; absent storage sorts first.All remaining types (
Bool,Void,Error, the unsigned integers,Timepoint,Duration,Address,LedgerKeyContractInstance) consist of non-negative big-endian fields in XDR field order, so their XDR encodings compare in host order.
Declaration
Swift
public func compareScValHostOrder(_ a: SCValXDR, _ b: SCValXDR) -> IntParameters
aThe first value to compare.
bThe second value to compare.
Return Value
A negative value when
asorts beforeb, zero when the two values are equal under the host order, and a positive value whenasorts afterb. - Values of different types compare by their
View on GitHub
Install in Dash
Functions Reference