structs.sol

Overview

This Solidity source file defines a simple data structure named MessageInfo. Its primary purpose is to encapsulate key information about a message, specifically a hashed identifier and an expiration timestamp. This struct can be used throughout the smart contract system to standardize message metadata handling, enabling consistent storage, retrieval, and verification of message-related data.

Structs

MessageInfo

Description

MessageInfo is a struct that groups two pieces of data related to a message:

Fields

Field Name

Type

Description

messageHash

uint256

Hash of the message, used as a unique identifier.

expireAt

uint32

Expiration time as a Unix timestamp (seconds).

Usage Example

// Example of initializing a MessageInfo struct
MessageInfo memory msgInfo = MessageInfo({
    messageHash: uint256(keccak256(abi.encodePacked("Hello World"))),
    expireAt: uint32(block.timestamp + 3600) // Expires in 1 hour
});

This struct can be used in mappings, arrays, or function parameters to track message validity and identification efficiently.

Implementation Details

Interaction with Other System Components

Diagram: Structure of structs.sol

classDiagram
class MessageInfo {
+uint256 messageHash
+uint32 expireAt
}

This diagram represents the single struct defined in the file, highlighting its two data fields.