If I pass in the string QmbPAr5RcCZZDRsNKnf2p1t6GK3Qu7oDH39HCK3aewUq3w to the sp.pack method in an entrypoint and perform and sp.trace in smartpy I expect to get the following bytes:


However, I receive the following bytes:


You can see that the bytes 0x05010000002e are being prepended to the value during the pack

Why does this happen?

1 Answer 1


0x05 means "this is a packed Michelson value". 0x01 means "this is a string". The remaining 4 bytes represent the length of the string.

A complete description of the binary format of Michelson values can be generated by the following command: tezos-codec describe alpha.script.expr binary schema.

  • interesting.. thank you. do you know if it is possible to turn a string sent into an entrypoint into its raw bytes representation within the entrypoint? i thought sp.pack would do this, and while sp.utils.bytes_of_string gives the right answer it is only available at compile time
    – 0x10
    Commented Jan 21, 2022 at 11:33
  • i expanded this comment into a full question: tezos.stackexchange.com/questions/4001/…
    – 0x10
    Commented Jan 21, 2022 at 11:44

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.