Skip to main content
Version: Next

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.

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.

size: (_: bytes) => nat

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

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.

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

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

sub: (index: nat, length: nat, bytes: 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.

slice: (index: nat, length: nat, bytes: 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.

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

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

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

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