orbis.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?
The createPost()
function accepts a JSON object that must contain a body
element which is the actual content of the post being shared.
let res = await orbis.createPost({body: "gm!"});
Parameters
content
: A JSON object that contains the details of the post being sharedbody
:string
Content of the post being sharedtitle
:string
optional
Title of the post (can be used for articles)context
:string
optional
Context in which the post is being shared. Can be a random string or a group / channel idmaster
:string
optional
If the post is being shared as a comment of a postreply_to
:string
optional
If the post shared is a reply to another comment in a threadmentions
:array
optional
Array of mentions if this post is mentioning other users, the array items must contain:did
:string
Did of the user being mentionedusername
:string
Current username of the usertags
:array
optional
Array of tags that can be used to filter posts in queries:slug
:string
Identifier for the tag (used in queries)title
:string
Title that can displayed in the app for examplemedia
:array
optional
An array of media object stored on IPFSurl
:string
URL of the image must start withipfs://
gateway
:string
URL of the IPFS gateway where the media is storeddata
:object
optional
Can be used to attach some custom data to a postencryptionRules
:object
optional
A JSON object containing the optional encryption rules for this post.type
:string
The type of encryption needed, can betoken-gated
orcustom
for now.chain
:string
The chain on which the smart contract is. Must be one of those in lowercasecontractType
:string
The type of contract being used, must beERC20
,ERC721
orERC1155
.contractAddress
:string
The address of the contract.minTokenBalance
:string
The minimum balance required to decrypt the post (in WEI forERC20
).tokenId
:string
optional
Used only forERC1155
tokens to represent thetokenId
used.accessControlConditions
:object
The custom Lit access control conditions you want to use to encrypt this post.
For the token-gated
posts:
For the custom
encryption rules:
Examples
/** To create a simple post in the global feed */
orbis.createPost({body: "hello everyone"});
/** To create a post in the 'gm' channel of the orbis group */
orbis.createPost({
body: "gm",
context: "kjz...kk3gn"
});
/** To create an encrypted post for Azuki holders */
orbis.createPost(
{
body: "Hello Azuki holders!"
},
{
type: "token-gated",
chain: "ethereum",
contractType: "ERC721",
contractAddress: "0xed5af388653567af2f388e6224dc7c4b3241c544",
minTokenBalance: "1"
}
);
/** Encrypt posts using custom access control conditions */
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'
}
}
]
}
);
Returns
{
status: 200,
doc: "kjzl6cwe1...e4wvxhiqj",
result: "Success creating TileDocument."
}