🗄️MessageData

The central data repository for all user posts data

Table of Contents


Events

logNewMsg

This event is triggered when a new message is posted. It logs the details of the message.

logRemoveMsg

This event is triggered when a message is removed. It logs the ID of the message that was removed.

logUpdateMsgStats

This event is triggered when the statistics of a message are updated. It logs the type of statistic, message ID, the updated value of the statistic, and tips.


Public Function

getPoster

This function returns the address of the user or group that posted a specific message.

Inputs

Name
Type
Description
Example

msgID

uint256

The ID of the message to check for the poster's address

1

Outputs

Name
Type
Description

address

The address of the member that posted the message

Example

Using ethers.js to call the getPoster function:

const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getPoster() {
    const poster = await contract.getPoster(msgID);
    console.log(`The message was posted by: ${poster}`);
}

getPoster();

getInGroups

This function returns a list of group IDs in which a specific message was posted.

Inputs

Name
Type
Description
Example

msgID

uint256

The ID of the message to check for

1

Outputs

Name
Type
Description

uint256[]

An array of group IDs that the message was posted in

Example

Using ethers.js to call the getInGroups function:

const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getInGroups() {
    const groups = await contract.getInGroups(msgID);
    console.log(`The message was posted in groups: ${groups}`);
}

getInGroups();

getMsgCommentLevel

This function returns the comment level of a post. If the return value is 0, comments are open. If the return value is 1, comments are closed.

Inputs

Name
Type
Description
Example

msgID

uint256

The ID of the message to check for

1

Outputs

Name
Type
Description

uint256

The comment level of the message

Example

Using ethers.js to call the getMsgCommentLevel function:

const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getMsgCommentLevel() {
    const commentLevel = await contract.getMsgCommentLevel(msgID);
    console.log(`The comment level of the message is: ${commentLevel}`);
}

getMsgCommentLevel();

Last updated