- createChannel
- channelRoot
- createMessage
- mamAttach
- mamFetch
- decodeAddress
- mamFetchAll
- decodeMessages
- parseMessage
▸ createChannel(seed
, security
, mode
, sideKey?
): IMamChannelState
Create a new channel object.
Name | Type | Description |
---|---|---|
seed |
string |
The seed for the channel. |
security |
number |
The security level for the channel. |
mode |
MamMode |
The mode for the channel. |
sideKey? |
string |
The side key to use for restricted mode. |
The new channel state.
▸ channelRoot(channelState
): string
Get the root of the channel.
Name | Type | Description |
---|---|---|
channelState |
IMamChannelState |
The channel state to get the root. |
string
The root.
▸ createMessage(channelState
, message
): IMamMessage
Prepare a message on the mam channel.
Name | Type | Description |
---|---|---|
channelState |
IMamChannelState |
The channel to prepare the message for. |
message |
string |
The trytes to include in the message. |
The prepared message, the channel state will also be updated.
▸ mamAttach(client
, mamMessage
, tag?
): Promise
<{}>
Attach the mam message to the tangle.
Name | Type | Description |
---|---|---|
client |
string | IClient |
The client or node endpoint to use for sending. |
mamMessage |
IMamMessage |
The message to attach. |
tag? |
string |
Optional tag for the transactions. |
Promise
<{}>
The transactions that were attached.
▸ mamFetch(client
, root
, mode
, sideKey?
): Promise
<IMamFetchedMessage
| undefined
>
Fetch a mam message from a channel.
Name | Type | Description |
---|---|---|
client |
string | IClient |
The client or node endpoint to use for fetching. |
root |
string |
The root within the mam channel to fetch the message. |
mode |
MamMode |
The mode to use for fetching. |
sideKey? |
string |
The sideKey if mode is restricted. |
Promise
<IMamFetchedMessage
| undefined
>
The decoded message and the nextRoot if successful, undefined if no messages found, throws exception if transactions found on address are invalid.
▸ decodeAddress(root
, mode
): string
Decodes the root to its associated address.
Name | Type | Description |
---|---|---|
root |
string |
The root to device. |
mode |
MamMode |
The mode for the channel. |
string
The decoded address.
▸ mamFetchAll(client
, root
, mode
, sideKey?
, limit?
): Promise
<IMamFetchedMessage
[]>
Fetch all the mam message from a channel. If limit is undefined we use Number.MAX_VALUE, this could potentially take a long time to complete. It is preferable to specify the limit so you read the data in chunks, then if you read and get the same amount of messages as your limit you should probably read again.
Name | Type | Description |
---|---|---|
client |
string | IClient |
The client or node endpoint to use for fetching. |
root |
string |
The root within the mam channel to fetch the message. |
mode |
MamMode |
The mode to use for fetching. |
sideKey? |
string |
The sideKey if mode is restricted. |
limit? |
number |
Limit the number of messages retrieved. |
Promise
<IMamFetchedMessage
[]>
The array of retrieved messages.
▸ decodeMessages(messages
, root
, sideKey?
): Promise
<IMamFetchedMessage
| undefined
>
Decode messages from an address to try and find a MAM message.
Name | Type | Description |
---|---|---|
messages |
IMessage [] |
The objects returned from the fetch. |
root |
string |
The root within the mam channel to fetch the message. |
sideKey? |
string |
The sideKey if mode is restricted. |
Promise
<IMamFetchedMessage
| undefined
>
The decoded message and the nextRoot if successful, undefined if no messages found, throws exception if transactions found on address are invalid.
▸ parseMessage(payload
, root
, channelKey?
): Object
Parse the trytes back to the original message.
Name | Type | Description |
---|---|---|
payload |
string |
The trytes to decode. |
root |
string |
The root for the message. |
channelKey? |
string |
The key used to encode the data. |
Object
The decoded message.
Name | Type | Description |
---|---|---|
nextRoot |
string |
The next root. |
message |
string |
The decoded message. |
Ƭ MamMode: "public"
| "private"
| "restricted"
The modes for MAM.