description |
---|
Call the .submit function to create an aggregate of a key-value pair for an address. |
The function will return the aggregate message object created.
If no account is passed in the optional object parameter, the aggregate won't actually be written to the network (aka you would be running a test).
import { aggregates } from 'aleph-js'
await aggregates.submit(address, key, content)
// OR with additional optional parameters:
await aggregates.submit(address, key, content, { account: account })
Parameter | Description |
---|---|
address - string | Address the Aggregate should be associated with |
key - string | Key to mutate |
content - object | The value content object to save for the key. |
In addition to the required parameters above, an object of optional parameters can be passed following the content object like so:
aggregates.submit(address, key, content,
{channel: "my_channel", account: account}
)
-
api_server - string
Default: "https://api1.aleph.im"
Target API server
-
chain - string
Default: null
The chain used by the sender's account. Value can be
NULS2
,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
Default: "storage"
Storage engine to use. Possible values:
storage
,ipfs
-
account - Account | required for writing to the network
Default: null
Sender's account to use for signing.
ℹ️ Needed if you want to send and save the message on the network. Without it, it is a dry run.
{% code title="CREATE AN AGGREGATE OF KEY-VALUE PAIR FOR ADDRESS" %}
import { aggregates } from 'aleph-js'
await aggregates.submit(
account.address,
'first_key',
{'a': 1, 'b': 2},
{
'account': account,
'channel': 'TEST'
}
)
{% endcode %}
{% code title="RESPONSE" %}
{
chain: 'ETH',
channel: 'TEST',
sender: '<SENDER ADDRESS WILL DISPLAY HERE>',
type: 'AGGREGATE',
time: 1629228489.081,
item_type: 'inline',
item_content: '{"address":"<YOUR SENDER ADDRESS WILL DISPLAY HERE>",
"key":"first_key",
"content":{"a":1,"b":2},
"time":1629228489.081}',
item_hash: '251f6bc2d4e61713a91c255d91011c6d50fbd786eadb6640ec8d3c86e311c9be',
signature: '0xe078056f7a8192a9f44d1b57dd78e35e2aae1b5ce17824180be943d717d6969a09d654139326a3d7c945ddc91f8699eaff65f4b6c67ebc40fe09fd319101a9171c'
}
{% endcode %}