Solidity Struct

List of Solidity structs used in Faracle smart contracts.

FarUserData Struct

Holds user profile related data like followers, following, timestamps, flags, etc.
YourContract.sol
1contract StructFarUserData {
2  
3  struct FarUserData {
4    uint32 followers;         // number of followers
5    uint32 following;         // number of following
6    uint32 accountCreated;    // account creation timestamp, all time in unix epoch and most profile wont have this data
7    uint32 lastActiveTime;    // last active timestamp in Farcaster snapchain, this is not live yet
8    uint32 timestampSource;   // timestamp when this data is fetched from source
9    uint32 timestamp;         // timestamp when this data is stored on chain
10    uint32 timestampAddress;  // timestamp when the verified address updated onchain for this fid 
11    uint24 flags;             // various flags. Check for UserFlags struct
12    uint8  addressSize;       // number of verified addresses linked to this fid
13  }
14
15}
Note: Whole struct can be packed into a single 32 byte storage slot.

UserFlags Struct

Bit-packed struct to hold various flags related to a user.

This fits inside 'flags' field of FarUserData struct.

YourContract.sol
1contract StructUserFlags {
2  
3  struct UserFlags {
4  
5    bool proSubscription;   //Bit 00-00 : Pro Subscription  (Boolean)
6    bool channelOwner;      //Bit 01-01 : Channel Owner     (Boolean)
7    bool channelModerator;  //Bit 02-02 : Channel Moderator (Boolean)
8    bool isSpammy;          //Bit 03-03 : Is it Spammy.     (true means '0' or '1' which is spam or likely spam)
9                            // Bits 04-23 : Reserved for future use   
10  }
11
12}
Note: Whole struct can be packed into a single 3 byte storage slot.

TimestampedValue Struct

Generic struct to hold a value along with its associated timestamps.
YourContract.sol
1contract StructTimestampedValue {
2  
3  struct TimestampedValue {
4    uint32  timestampChain;  // timestamp when data was recorded on-chain
5    uint32  timestampSource; // timestamp when data was fetched from the source (off-chain like snapchain, debank, or internal system)
6    uint192 value;           // the actual value being recorded (e.g., net worth, score, etc.)
7  }
8
9}
Note: Whole struct can be packed into a single 32 byte storage slot.

UserChannelStats Struct

Holds statistics related to user's metric about channels like leads, moderating, members, and following counts.

This fits inside 'value' field of TimestampedValue struct.

YourContract.sol
1contract StructUserChannelStats {
2  
3  struct UserChannelStats {
4  
5    uint32 channelsLead;        // Number of channels where user is lead
6    uint32 channelsModerating;  // Number of channels where user is moderator
7    uint32 channelsMember;      // Total number of members
8    uint32 channelsFollowing;   // Total number of channels followed by this user
9                                // Rest of the slots are reserved for future use
10  }
11
12}
Note: Whole struct should be packed into 24 byte storage slot.

ChannelUser Struct

Holds user specific data within a channel like timestamps for followed, member, restricted, banned status, and flags for lead/moderator.
YourContract.sol
1contract StructChannelUser {
2  
3  struct ChannelUser {
4  
5    // Timestamps
6    uint32 followedAt;      //4 Bytes Timestamp when followed
7    uint32 memberAt;        //4 Bytes Timestamp when became member
8    uint32 restrictedAt;    //4 Bytes Timestamp when restricted
9    uint32 bannedAt;        //4 Bytes Timestamp when banned
10
11    // meta 
12    uint32 timestamp;       //4 Bytes: When this data was last updated.
13
14    // Flags 
15    bool isLead;            //1 Bit:  Includes Lead and moderator status
16    bool isModerator;       //1 Bit:  Includes Lead and moderator status
17
18    // Rest of the slots are reserved for future use
19  }
20
21}
Note: Whole struct can be packed into a single 32 byte storage slot.