Version: 0.25.0

Bytes

let concat: (a: bytes, b: bytes) => bytes

Concatenate together two bytes arguments and return the result.

let concat_op = (s: bytes): bytes => Bytes.concat(s, 0x7070);
let sub : (start: nat, length: nat, input: bytes) => bytes

Extract bytes from start to length. For example if you gave the input "ff7a7aff" to the following function:

let slice_op = (s: bytes): bytes => Bytes.sub(1 as nat, 2 as nat, s);

It would return "7a7a".

let pack : (data: 'a) => bytes

Converts Michelson data structures to a binary format for serialisation.

⚠️ PACK and UNPACK are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as UNPACKing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.

let id_string = (p: string) : option<string> => {
let packed : bytes = Bytes.pack(p);
return (Bytes.unpack(packed) as option<string>);
};
let unpack: (serialized_data: bytes) => option<'a>

Reverses the result of using pack on data.

As the conversion might fail an option type is returned.

⚠️ PACK and UNPACK are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as UNPACKing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.

let id_string = (p: string) : option<string> => {
let packed : bytes = Bytes.pack(p);
return (Bytes.unpack(packed) as option<string>);
};
let length: (b: bytes) => nat