Skip to main content
Version: 1.7.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 Bytes.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 Bytes.size(b) is the number of bytes in the sequence of bytes b.

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

The call Bytes.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 Bytes.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 Bytes.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 Bytes.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 Bytes.pack(v) transforms the value v into a sequence of bytes.

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

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