Complete the code to declare a packed struct with two uint128 variables.
struct Data {
uint128 a;
uint128 [1];
}The struct has two variables: a and b, both uint128 to pack efficiently.
Complete the code to pack three variables efficiently in a struct.
struct Packed {
uint64 x;
uint64 y;
[1] z;
}Using uint64 for z keeps all three variables at 64 bits each, allowing efficient packing into 192 bits total.
Fix the error in the struct to pack variables efficiently without wasting space.
struct Example {
uint256 a;
uint128 [1];
uint128 c;
}The variable name should be b to keep consistent naming and packing order.
Fill both blanks to declare a struct with packed variables for gas savings.
struct Storage {
[1] flag;
[2] count;
}Using bool and uint8 packs variables tightly, saving gas.
Fill all three blanks to create a packed struct with an address and two small integers.
struct PackedData {
[1] owner;
[2] level;
[3] score;
}The address type is 20 bytes, uint8 and uint16 are small integers that pack efficiently.