Pack and unpack
Pack and Unpack are used for serializing/deserializing pieces of data. It heavily relies on sp.TBytes type.
PackingConverts a given michelson value into sp.TBytes;
UnpackingDoes the inverse of pack, by deserializing sp.TBytes back to the michelson value.
It is useful when building generic smart contracts with entrypoints expecting sp.TBytes to then deserialize it to an internal structure. Also necessary when verifying signed contents.
Serialize a piece of data
<data> to its optimized binary representation of type sp.TBytes.
someRecord = sp.record(x = 1) bytes = sp.pack(someRecord)
Return an object of type sp.TBytes.Michelson PACK
Parse the serialized data from its optimized binary representation of type sp.TBytes into its original form.
There is an optional argument
t to specify the type of its deserialized form.
someRecord = sp.unpack(someRecord, sp.TNat)
Return an object of type