Skip to main content
Version: 1.4.0

Bytes

Sequences of bytes

Bytes are used for serializing data, in order to check signatures
and compute hashes on them. They can also be used to read untyped
data from outside of the contract.

let length: (_: bytes) => nat

The call length(b) is the number of bytes in the sequence of bytes b. Note: Bytes.length is another name for Bytes.size.

let size: (_: bytes) => nat

The call size(b) is the number of bytes in the sequence of bytes b.

let concat: (_: bytes) => (_: bytes) => bytes

The call concat(left, right) is the sequence of bytes obtained by concatenating the sequence left before the sequence right.

let concats: (_: list<bytes>) => bytes

The call concats(list) is the concatenation of the byte sequences in the list list, from left to right.

let sub: (_: nat) => (_: nat) => (_: bytes) => bytes

The call sub(index, len, bytes) is the subsequence of bytes bytes starting at index index (0 denoting the first byte) and of length len. If the index or length are invalid, an exception interrupts the execution.

let slice: (_: nat) => (_: nat) => (_: bytes) => bytes

The call slice(index, len, bytes) is the subsequence of bytes bytes starting at index index (0 denoting the first byte) and of length len. If the index or length are invalid, an exception interrupts the execution.

let pack: <a>(_: a) => bytes

The call pack(v) transforms the value v into a sequence of bytes.

let unpack: <a>(_: bytes) => option<a>

The call unpack(bytes) is Some(v) if the sequence of bytes bytes decodes into a valid LIGO value v; otherwise None().