The custom types example demonstrates how to define your own types.
Error enum types are another type contracts can define that have some unique behaviors. See Errors for more information.
Structs (with Named Fields)
Structs with named fields are stored on ledger as a map of key-value pairs, where the key is a 32 character string representing the field name, and the value is the value encoded. Field names must be no more than 32 characters. Fields with names no longer than 9 characters are slightly more efficient at runtime, though the difference should be marginal most of the time.ScVal, containing an ScMap, containing an array of key-value pairs.
Structs (with Unnamed Fields)
Structs with unnamed fields are stored on ledger as a vector of values, and are interchangeable with tuples and vectors. The elements are placed in the vector in order that they appear in the field list.ScVal, containing an ScVec, containing an array of values.
Enum (Unit and Tuple Variants)
Enums containing unit and tuple variants are are stored on ledger as a two element vector, where the first element is the name of the enum variant as a string up to 32 characters in length, and the value is the value if the variant has one. Only unit variants and tuple variants, likeA and B below, are supported.
Enum::A, is converted to XDR, the value becomes an ScVal, containing an ScVec, containing an array with a single value, the symbol containing the variant name.
Enum::B, is converted to XDR, the value becomes an ScVal, containing an ScVec, containing an array with two values, the symbol containing the variant name and the tuple value.
Enum (Integer Variants)
Enums containing integer values are stored on ledger as theu32 value.
ScVal, containing a U32.