1.0.1 • Published 8 months ago

@feiyangl1020/metaid-create-buzz v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

@feiyangl1020/metaid-create-buzz 🐝

npm version License: ISC GitHub Repository

A TypeScript library for creating and managing Buzz content on the MetaID protocol. Buzz is a decentralized social media post format that supports both public and pay-to-view content with media attachments.

Table of Contents

Features

  • Create normal Buzz posts with text and media attachments
  • Create pay-to-view Buzz posts with encrypted content
  • Support both BTC and MVC chains
  • Handle image and video uploads
  • Support NFT attachments
  • Configurable fee rates and network settings

Installation

npm install @feiyangl1020/metaid-create-buzz
# or
yarn add @feiyangl1020/metaid-create-buzz
# or
pnpm add @feiyangl1020/metaid-create-buzz

Usage

Basic Setup

import { createBuzz, createNormalBuzz } from '@feiyangl1020/metaid-create-buzz';

// Initialize with your connector and network settings
const params = {
  buzz: {
    content: "Hello MetaID!",
    publicImages: [], 
    encryptContent: "",
    encryptImages: [],
    nfts: []
  },
  host: "https://api.metaid.io",
  feeRate: 1,
  chain: "btc",
  btcConnector: yourBtcConnector,
  mvcConnector: yourMvcConnector,
  network: "testnet"
};

// Create a normal buzz
const txId = await createNormalBuzz(params);

// Create a pay-to-view buzz
const payParams = {
  ...params,
  isPayBuzz: true,
  payInfo: {
    manPubKey: "your_pubkey",
    payType: "btc",
    payAmount: 1000,
    manDomain: "your.domain"
  }
};
const payTxId = await createBuzz(payParams);

API Reference

createBuzz(params: Props)

Creates a pay-to-view Buzz post with encrypted content.

Parameters

  • params: Configuration object containing:
    • buzz: Buzz content details
    • host: MetaID API host
    • feeRate: Transaction fee rate
    • chain: Blockchain ("btc" or "mvc")
    • btcConnector: BTC wallet connector
    • mvcConnector: MVC wallet connector
    • network: Network ("mainnet" or "testnet")
    • isPayBuzz: Whether this is a pay-to-view buzz
    • payInfo: Payment configuration

createNormalBuzz(params: Props)

Creates a normal public Buzz post.

Dependencies

  • @feiyangl1020/metaid
  • browser-image-compression
  • compressorjs
  • crypto-js
  • uuid

Development

To set up the development environment:

git clone https://github.com/feiyang1020/metaid-create-buzz.git
cd metaid-create-buzz
pnpm install

Building

npm run build

Builds the project to the dist folder using TypeScript.

Testing

Run unit tests with Jest:

npm test

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a pull request

License

ISC © feiyang1020