createPost
Used to share a new Post on Orbis.
Can be used to share posts in a specific context or in the global feed.
If you are sharing an encrypted post you will need to use the orbis.decryptPost() function to decrypt the content.
How to use?
const res = await orbis.createPost(content, encryptionRules);Parameters
content- A JSON object that contains the details of the post being sharedbody-stringContent of the post being sharedtitle-stringoptionalTitle of the post (can be used for articles)context-stringoptionalContext in which the post is being shared. Can be a random string or a group / channel idmaster-stringoptionalIf the post is being shared as a comment of a postreply_to-stringoptionalIf the post shared is a reply to another comment in a threadmentions-arrayoptionalArray of mentions if this post is mentioning other users, the array items must contain:did-stringDid of the user being mentionedusername-stringCurrent username of the user
tags-arrayoptionalArray of tags that can be used to filter posts in queries:slug-stringIdentifier for the tag (used in queries)title-stringTitle that can be displayed in the app for example
media-arrayoptionalAn array of media objects stored on IPFSurl-stringmedia URL must start with ipfs://gateway-stringURL of the IPFS gateway where the media is stored
data-objectoptionalCan be used to attach some custom data to a post
encryptionRules-objectoptionalA JSON object containing the optional encryption rules for this post.type-stringThe type of encryption needed, can be token-gated or custom for now.token-gated(Token-gated posts):chain-stringThe chain on which the smart contract is. Must be one of those in lowercasecontractType-stringThe type of contract being used, must be ERC20, ERC721 or ERC1155.contractAddress-stringThe address of the contract.minTokenBalance-stringThe minimum balance required to decrypt the post (in WEI for ERC20).tokenId-stringoptionalUsed only for ERC1155 tokens to represent the tokenId used.
custom(Custom encryption rules):accessControlConditions-objectThe custom Lit access control conditions you want to use to encrypt this post.
Returns
{
status: 200,
doc: "kjzl6cwe1...e4wvxhiqj",
result: "Success creating TileDocument."
}Examples
Create a post in the global feed
orbis.createPost({
body: "hello everyone"
});Create a post in a specific context
orbis.createPost({
body: "gm",
context: "kjz...kk3gn"
});Create an encrypted post using token gating
In this example, only Azuki holders on Ethereum mainnet can read the post.
orbis.createPost(
{
body: "Hello Azuki holders!"
},
{
type: "token-gated",
chain: "ethereum",
contractType: "ERC721",
contractAddress: "0xed5af388653567af2f388e6224dc7c4b3241c544",
minTokenBalance: "1"
}
);Encrypt a post using a custom access control conditions
In this example, only people with more than 0.00001 ETH on Ethereum mainnet can read the post.
orbis.createPost(
{
body: "Post visible for wallets with at least 0.00001 ETH."
},
{
type: "custom",
accessControlConditions: [
{
contractAddress: '',
standardContractType: '',
chain: "ethereum",
method: 'eth_getBalance',
parameters: [
':userAddress',
'latest'
],
returnValueTest: {
comparator: '>=',
value: '10000000000000'
}
}
]
}
);