Frames
Frames are the lowest level data format in the OP Stack protocol.
Where Frames fit in the OP Stack
Transactions posted to the data availability layer of the rollup contain one or multiple Frames. Frames are chunks of raw data that belong to a given Channel, the next, higher up data format in the OP Stack protocol. Importantly, a given transaction can contain a variety of frames from different channels, allowing maximum flexibility when breaking up channels into batcher transactions.
Contents of a Frame
A Frame is comprised of the following items.
- A 
ChannelIdwhich is a 16 byte long identifier for the channel that the given frame belongs to. - A 
numberthat identifies the index of the frame within the channel. Frames are 0-indexed and are bound tou16size limit. datacontains the raw data within the frame.is_lastmarks if the frame is the last within the channel.
Frame Encoding
When frames are posted through a batcher transaction, they are encoded as a contiguous list with a single byte prefix denoting the derivation version. The encoding can be represented as the following concatenated bytes.
encoded = DERIVATION_VERSION_0 ++ encoded_frame_0 ++ encoded_frame_1 ++ ..
Where DERIVATION_VERSION_0 is a single byte (0x00) indicating the derivation
version including how the frames are encoded. Currently, the only supported
derivation version is 0.
encoded_frame_0, encoded_frame_1, and so on, are all Frames encoded
as raw bytes. A single encoded Frame can be represented by the following
concatenation of it's fields.
encoded_frame = channel_id ++ frame_number ++ frame_data_length ++ frame_data ++ is_last
Where ++ represents concatenation. The frame's fields map to it's encoding.
channel_idis the 16 byte longFrame::id.frame_numberis the 2 byte long (oru16)Frame::number.frame_data_lengthandframe_dataprovide the necessary details to decode theFrame::data, whereframe_data_lengthis 4 bytes long (oru32).is_lastis a single byteFrame::is_last.
maili's Frame Type
maili-protocol provides the Frame type with a few useful
methods. Frames can be encoded and decoded using the Frame::encode
and Frame::decode methods. Given the raw batcher transaction data or blob data
containing the concatenated derivation version and contiguous list of encoded frames,
the Frame::parse_frame and Frame::parse_frames methods
provide ways to decode single and multiple frames, respectively.