OpenMSCP
  • Welcome
    • Introduction
    • OpenMSCP
  • Tokenomics
  • OpenMSCP SDK
    • About
    • Prerequisities & Installation
    • Quick Start
    • SDK Core
      • Profiles
      • Posts
      • Messaging
    • Contributing
  • MSCP Social
    • What is MSCP Social?
    • Registration
    • Features
Powered by GitBook
On this page
  • Creating Profiles
  • Profile Data Structure
  • Profile Updates
  • Profile Verification
  • Profile Queries
  • Profile Events
  1. OpenMSCP SDK
  2. SDK Core

Profiles

Creating Profiles

The SDK provides comprehensive tools for managing user profiles on the OpenMSCP protocol.

Profile Creation

// Basic profile creation
const profile = await client.profile.create({
  username: 'alice',
  bio: 'Blockchain enthusiast',
  profilePicture: 'ipfs://QmHash...'
});

// Profile with additional metadata
const detailedProfile = await client.profile.create({
  username: 'bob',
  bio: 'Web3 developer',
  profilePicture: 'ipfs://QmHash...',
  metadata: {
    location: 'New York',
    website: 'https://example.com',
    socialLinks: {
      twitter: '@bob',
      github: 'bobdev'
    }
  }
});

Profile Validation

// Validate username format
const isValidUsername = await client.profile.validateUsername('alice123');

// Check username availability
const isAvailable = await client.profile.isUsernameAvailable('alice123');

// Validate profile data
const validation = await client.profile.validate({
  username: 'alice',
  bio: 'Blockchain enthusiast'
});

Profile Data Structure

Core Profile Fields

interface Profile {
  publicKey: PublicKey;
  username: string;
  bio: string;
  profilePicture: string;
  createdAt: number;
  updatedAt: number;
  metadata?: {
    location?: string;
    website?: string;
    socialLinks?: {
      twitter?: string;
      github?: string;
      // ... other social platforms
    };
  };
}

Profile Statistics

interface ProfileStats {
  posts: number;
  followers: number;
  following: number;
  likes: number;
  comments: number;
}

Profile Updates

Updating Profile Information

// Update basic profile information
await client.profile.update({
  bio: 'Updated bio',
  profilePicture: 'ipfs://QmNewHash...'
});

// Update metadata
await client.profile.updateMetadata({
  location: 'San Francisco',
  website: 'https://new-website.com'
});

// Partial updates
await client.profile.partialUpdate({
  bio: 'New bio only'
});

Profile Picture Management

// Upload profile picture
const pictureHash = await client.profile.uploadPicture(file);

// Update profile picture
await client.profile.updatePicture(pictureHash);

// Remove profile picture
await client.profile.removePicture();

Profile Verification

Verification Process

// Request verification
const verificationRequest = await client.profile.requestVerification();

// Check verification status
const status = await client.profile.getVerificationStatus();

// Complete verification
await client.profile.completeVerification(verificationCode);

Verification Types

enum VerificationType {
  EMAIL = 'email',
  PHONE = 'phone',
  SOCIAL = 'social',
  GOVERNMENT = 'government'
}

// Request specific verification type
await client.profile.requestVerification(VerificationType.EMAIL);

Profile Queries

Basic Queries

// Get profile by public key
const profile = await client.profile.get(publicKey);

// Get profile by username
const profile = await client.profile.getByUsername('alice');

// Get multiple profiles
const profiles = await client.profile.getMany([publicKey1, publicKey2]);

Advanced Queries

// Search profiles
const results = await client.profile.search({
  query: 'alice',
  limit: 10,
  offset: 0
});

// Filter profiles
const filtered = await client.profile.filter({
  location: 'New York',
  verified: true,
  minFollowers: 100
});

// Get profile statistics
const stats = await client.profile.getStats(publicKey);

Profile Relationships

// Follow a profile
await client.profile.follow(targetPublicKey);

// Unfollow a profile
await client.profile.unfollow(targetPublicKey);

// Get followers
const followers = await client.profile.getFollowers(publicKey);

// Get following
const following = await client.profile.getFollowing(publicKey);

// Check relationship
const relationship = await client.profile.getRelationship(targetPublicKey);

Profile Events

The SDK provides event listeners for profile-related activities.

// Listen for profile updates
client.profile.onUpdate((profile) => {
  console.log('Profile updated:', profile);
});

// Listen for new followers
client.profile.onNewFollower((follower) => {
  console.log('New follower:', follower);
});

// Listen for verification status changes
client.profile.onVerificationStatusChange((status) => {
  console.log('Verification status changed:', status);
});
PreviousSDK CoreNextPosts

Last updated 1 month ago