Running the PACK operation on a tuple (represented as a pair in Michelson, I get

$ ligo interpret -s pascaligo 'Bytes.pack((1, 2))'

The numbers 1 and 2 are serialized as 0001 and 0002, respectively.

The tuple (1,2) is represented as PAIR 1 2 in Michelson and PAIR serializes to 0x07. So why are there two 0x07 values, and not just one?

1 Answer 1


Here is a break down:

Let's try another example. What is the encoding of the value Left 1 of type or nat bool? Per tezos-client hash data 'Left 1' of type 'or nat bool', it will be 0x05 05 05 0001, where:

  • 05: the fixed prefix denotes a michelson data value, as above.
  • 05: the expression Left 1 is a primitive application with one argument and no annotations. The corresponding tag is also 0x05.
  • 05: the michelson primitive is Left, for which the corresponding tag is also 05.
  • 0001: encoding of the integer 1.
  • OK, so 07 means both the Pair type constructor, and primitive. Got it. I would have though the first 07 was the primitive value and only the 2nd was the Pair type constructor, though. Oct 5, 2020 at 11:10
  • I'm not sure I understand your last phrase: what do you mean with "primitive value"? and note that Pair is not a type constructor but a data constructor. However, pair is a type constructor (admittedly, it is confusing). Lowercase keywords are types, and capitalized keywords are data constructors. Example: Pair is a constructor that constructs values of type pair x y. pair is a type constructor with two arguments.
    – arvidj
    Oct 5, 2020 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.