The mathematical structure of a set is an unordered collection. If a set does not have an order, how are they serialized by the
According to this overview
set is packable.
Tezos Stack Exchange is a question and answer site for users, experts, and developers of the Tezos blockchain project. It only takes a minute to sign up.Sign up to join this community
Sets are serialized by first ordering the elements, and then packing them as a sequence which is also how lists are represented when
PACK is called. This means that these two expressions evaluate to the same, since they are first sorted, and then serialized.
ligo interpret -s pascaligo 'Bytes.pack(set [ 1; 2; 3; 4 ])' ligo interpret -s pascaligo 'Bytes.pack(set [ 4; 2; 3; 1 ])'
Both output the same byte array
05is the prefix for any output from the
02is the tag for the sequence type
00000008is the four bytes indicating the size of the coming values, in bytes
0001000200030004are then numbers
1,2,3,4encoded with first a
00tag to indicate that this is a integer, and the numbers
04are the encoding of the actual numbers.