Reference Implementation
Every activity performed by a user can be described as a message with the follow schema:
Message
{
id: STRING[255],
type: STRING[15],
subtype: STRING[15],
creator: STRING[65535],
createdAt: UINT64,
payload: OBJECT, // Depends on message type
}
Unique message ID based on the content hash of the message. See “Message ID” section.
Main type describing the primary purpose of the message
Sub type describing the secondary purpose of the message
Domain names of the creator (e.g. bob.eth, alice.crypto, etc)
Unix timestamp in seconds of when the message was created
Schema containing data of a message depends on type
Message ID
We should hex-encode the message based on the following pseudo code in order to create a deterministic SHA256 hash.
const type = hexString(message.type.toUpperCase()); // e.g. "POST" -> 504f5354
const subtype = hexString(message.subtype.toUpperCase());
const creator = hexString(message.creator); // ETH address
const createdAt = hexUint32(message.createdAt); // e.g. 1624773198 -> 60D8124E
const payload = hex(message.payload); // hex order based on message types
const encode = [
uint8len(hash), hash, // "POST" -> 504f5354 -> 8504f5354
uint8len(subtype), subtype, // "" -> "" -> 0
uint16len(creator), creator, // "bob.eth" -> 626f622e657468 -> 000e626f622e657468
createdAt, // 1624780498 -> 0000000060d82ed2
payload
].join('');
const messageHash = crypto.createHash('sha256').update(encode).digest('hex');
const messageId = creator + '/' + messageHash; // e.g. 0x1234...7890/42740f20aed483b69701a55ab295a2ed
A message can be used to described user activities such as a post, comment, likes, and follow.
Profile Message
The PROFILE type is used to support adding profile data to a name.
value of the profile data
Custom key of profile data
Custom value of profile data
Post Message
The POST type is used to support posts (similar to tweets, status update, etc), comments, and reposts.
Topic of the post for ease of discovery. (e.g. sports, news)
Plain text containing the title of the Post
Markdown text containing content of the Post
url or file message hash being attached to the message
File Message
The File type is used to support adding file to a name
magnetURI for the torrent
Moderation Message
The MODERATION type is used to support moderation activities, such as a LIKE, UPVOTE, DOWNVOTE, BAN, etc.
hash of the message receiving the moderation
Connection Message
The CONNECTION type is used to support follows and other types of links between names.
Domain names of the one being followed (e.g. bob.eth, alice.crypto, etc)