Data Types & Enums
Reference for common data types used in ChainSocial.
Bytes32
Many IDs (posts, content) are bytes32. In TypeScript:
type Bytes32 = `0x${string}` // 66 characters total (0x + 64 hex chars)Converting Strings to Bytes32
import { stringToHex, padHex } from 'viem'
// For usernames and short strings
const username = padHex(stringToHex('alice'), { size: 32 })
// Result: 0x616c696365000000000000000000000000000000000000000000000000000000Decoding Bytes32 to String
import { hexToString } from 'viem'
const decoded = hexToString(username).replace(/\0/g, '')
// Result: 'alice'Enums
PostVisibility
enum PostVisibility {
PUBLIC = 0,
FOLLOWERS = 1,
PRIVATE = 2
}| Value | Meaning |
|---|---|
PUBLIC (0) | Visible to everyone |
FOLLOWERS (1) | Visible only to followers |
PRIVATE (2) | Visible only to author |
ReactionType
enum ReactionType {
LIKE = 0
}Currently only LIKE is supported.
ContentStorageType
enum ContentStorageType {
INLINE = 0, // Data stored on-chain
IPFS = 1, // CID reference to IPFS
URL = 2 // External URL reference
}DelegationPermission
enum DelegationPermission {
POST = 0, // Create posts, replies, quotes
UPDATE_PROFILE = 1, // Modify profile fields
SEND_DMS = 2, // Send direct messages
FOLLOW = 3 // Follow/unfollow users
}Profile Metadata Schema
Profile metadata follows the CSPM-1 specification:
interface ProfileMetadata {
$schema?: string
version?: string
displayName?: string
bio?: string
avatar?: {
uri: string // ipfs:// or https:// URI
mimeType?: string
}
coverImage?: {
uri: string
mimeType?: string
}
website?: string
location?: string
occupation?: string
organization?: string
pronouns?: string
accountType?: string
links?: Array<{
type: string // 'twitter', 'github', 'discord', etc.
url: string
handle?: string
label?: string
verified?: boolean
}>
attributes?: Array<{
trait_type: string
value: string | number
display_type?: string
}>
updatedAt?: number
}API Response Types
Post
interface Post {
postId: string
author: string // Address
contentId: string
content: string | null
visibility: 'PUBLIC' | 'FOLLOWERS' | 'PRIVATE'
createdAt: number // Unix timestamp
editedAt: number | null
replyTo: string | null
quoteOf: string | null
isDeleted: boolean
isEdited: boolean
}Profile
interface Profile {
address: string
username: string
joinedAt: number
lastActiveAt: number
isVerified: boolean
isActive: boolean
metadata?: ProfileMetadata
}FeedItem
interface FeedItem {
post: Post
author: Profile | null
}Size Limits
| Item | Limit |
|---|---|
| Inline content | 4 KB (4096 bytes) |
| Profile field value | 2000 characters |
| Batch follows | 50 users |
| Batch posts | 50 posts |
| Post attachments | 10 per post |
| Delegation duration | 365 days max |
| Username length | 3-20 characters |