description |
---|
Call the .submit() function to create a Post |
The post object that was just created.
{% hint style="success" %}
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.
{% endhint %}
import { posts } from 'aleph-js'
await posts.submit(address, post_type, content)
// Or with optional parameters
await posts.submit(address, post_type, content, { channel: channel, account: account})
Parameter | Description |
---|---|
address - string | Address the Post should be associated with |
post_type - string | A lowercase string of your choice for the |
content - object | The content object to save to the If |
In addition to the required parameters above, an object of optional parameters can be passed following the content like so:
posts.submit(address, post_type, content,
{api_server: "https://api2.aleph.im"}
)
-
api_server - string
Default: "https://api1.aleph.im"
Target API server
-
ref - string
Default: null
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. -
chain - string
Default: null
The chain used by the sender's account.
Value can beNULS2
,ETH
,DOT
,CSDK
,SOL
,AVAX
-
channel - string
Default: null
Channel of the message. Ideally, an application would decide and use one channel.
-
inline - boolean
Default: true
Should the message be stored as a separate file or inserted inline?
ℹ️ Set it to false for data that could fall under GDPR.
-
storage_engine - string either
"ipfs"
or"storage"
Default: "storage"
Storage engine to use.
Possible values:storage
,ipfs
-
account - Account
Default: null
Account to use for signing.
ℹ️ Needed if you want to send the message. Without it, it is a dry run.
{% code title="CREATE POST" %}
import { posts } from 'aleph-js'
await posts.submit(
account.address,
'mytype',
{'body': 'test'},
{
'account': account,
'channel': 'TEST',
'api_server': 'https://api2.aleph.im'
}
)
{% endcode %}
{% code title="RESPONSE" %}
{
chain: 'NULS2',
channel: 'TEST',
sender: 'NULSd6HgcLR5Yjc7yyMiteQZxTpuB6NYRiqWf',
type: 'POST',
time: 1582555614.466,
item_type: 'inline',
item_content: '{
"type":"mytype",
"address":"NULSd6HgcLR5Yjc7yyMiteQZxTpuB6NYRiqWf",
"content":{"body":"test"},
"time":1582555614.466
}',
item_hash:'b546f70573a1a91a35a39dbacea0bbfe50847337dcbd995323994535847a6519',
signature: 'HGnCVb6Rnck5l/BfP93zR3/dvgVToK1yRiPTQrCZjKA/eMiUZwMkaSQFb/FMLvENTtZX804KRERGZxoxU1lEip0='
}
{% endcode %}