u256
A u256 value in Cairo is represented by two felt252 values, as follows:
The first felt252 value contains the 128 least significant bits, usually referred to as the low part of the original u256 value.
The second felt252 value contains the 128 most significant bits, usually referred to as the high part of the original u256 value.
i8, i16, i32, i64, i128
For these types, each value is serialized as a single-member list that contains one felt252 value. A negative value, ($-x$) , is serialized as $P-x$ , where:
$$P = 2^{252} + 17*2^{192} + 1$$
ByteArray
A string is represented in Cairo as a ByteArray type. A byte array is actually a struct with the following members:
data: Array<felt252>
Contains 31-byte chunks of the byte array. Each felt252 value has exactly 31 bytes. If the number of bytes in the byte array is less than 31, then this array is empty.
pending_word: felt252
The bytes that remain after filling the data array with full 31-byte chunks. The pending word consists of at most 30 bytes.
pending_word_len: usize
The number of bytes in pending_word.
Types that need to be supported:
u256
i8
,i16
,i32
,i64
,i128
ByteArray
u256
A u256 value in Cairo is represented by two felt252 values, as follows:i8
,i16
,i32
,i64
,i128
For these types, each value is serialized as a single-member list that contains one felt252 value. A negative value, ($-x$) , is serialized as $P-x$ , where: $$P = 2^{252} + 17*2^{192} + 1$$ByteArray
A string is represented in Cairo as aByteArray
type. A byte array is actually a struct with the following members:data: Array<felt252>
Contains 31-byte chunks of the byte array. Each felt252 value has exactly 31 bytes. If the number of bytes in the byte array is less than 31, then this array is empty.pending_word: felt252
The bytes that remain after filling the data array with full 31-byte chunks. The pending word consists of at most 30 bytes.pending_word_len: usize
The number of bytes in pending_word.Enums An enum is serialized as follows: