Create a post

Call the .submit() function to create a Post

Returns

A base message object that is being sent to the network.

Tips Pass a ref in the optional object parameter and/or tags in your content to take full advantage of the filtering abilities later on.

Usage & Example

import { post } from 'aleph-sdk-ts'
import { StorageEngine } from "aleph-sdk-ts/messages/message"

(async() => {
  await post.Publish({
    account: account,
    postType: 'mytype',
    content: {'body': 'test post written on Aug 17th'},
    channel: 'TEST',
    APIServer: 'https://api2.aleph.im',
    inlineRequested: true,
    storageEngine: StorageEngine.STORAGE
  })
})()

// Returns the message that is being sent to the network
{
  chain: "<YOUR ACCOUNT CHAIN>",
  channel: "TEST",
  confirmed: false,
  item_content: "{\"type\":\"mytype\",\"address\":\"<YOUR ADDRESS APPEAR HERE>\",\"content\":{\"body\":\"test post written on Aug 17th\"},\"time\":1636137569.869}",
  item_hash: "8671a9bb4dac018a0bd8b5c56ac883fd551f43af2b01d34e60215a8419d555b0",
  item_type: "INLINE",
  sender: "<YOUR ADDRESS APPEAR HERE>",
  signature: "0x0338f9c3ae1eb4715a923094f4ee5459a3131e54b393b9640c137f11cb5fc8c131299723fb19c2cdd971ee60c6cd68bb9643c93d92e918e8be1ec787657da9631b",
  size: 0,
  time: 1636137569.869,
  type: "POST"
}

Required parameters

ParameterDescription

account - Account

Address the Post should be associated with or the address that submitted the Post.

postType - string

A lowercase string of your choice for the item_content.type of the post message. ex: amend,blog, chat, comment

content - object

The content object to save to the item_content.content of the post message.

If tags are passed within the object, they can be searched for later on.

channel - string

Channel of the message. Ideally, an application would decide and use one channel.

inlineRequested - boolean

Should the message be stored as a separate file or inserted inline?

storageEngine - StorageEngine

Storage engine to use, either Aleph storage or IPFS.

Possible values: StorageEngine.STORAGE or StorageEngine.IPFS

APIServer - string

Target API server

Optional parameters

  • ref - string or object with the following structure

{ chain: string; 
channel? : string;
item_content: string;
item_hash: string;
item_type: string;
sender: string;
signature: string;
time: number;
type:string; }

A searchable reference string of your choice to save to the item_content.ref. Can be the reference to another post, an address, transaction hash, etc.

Last updated