Messaging
In this section, methods related to messaging management are covered
Create Message
ArianeeWallets.methods.createMessage(data)
Creates a message
Parameter
data
-object
: message creation data objectcontentImprint
-string
(optional): message content imprint. (either contentImprint or content need to be provided)certificateId
-number
: arianee token id. Random if left emptymessageId
-number
: (optional) message id. Random if left emptycontent
-object
(optional) : message content object (json). (either contentImprint or content need to be provided)
Result
promise
returns object
: The receipt of the blockchain transaction + keys :
contentImprint
-string
(optional): message content imprint.messageId
-number
: message id.
This method performs a blockchain transaction. It costs 1 message credit and Gas.
Example
const message={
certificateId,
content: {
$schema: 'https://cert.arianee.org/version1/ArianeeMessage-i18nAlpha.json',
title:'message title',
content:'message content'
}
}
const { contentImprint, messageId } = await await wallet.methods.createMessage(event);
Store message's content
ArianeeWallets.methods.storeMessage(certificateId, messageId, content, url)
Store content of message on a arianee-rpc-server (https://github.com/Arianee/arianee-rpc-server).
Parameter
certificateId
-number
: arianee token id.messageId
-number
: message id.content
-object
: message content object (json)uri
-string
: uri of rpc server where you want to store event content. It should be certificate issuer's rpc server.
Result
promise
returns any
Example
await wallet
.methods
.storeMessage(
certificateId,
messageId,
message.content,
'https://http://arianee.cleverapps.io/testnet/rpc');
Get a message
ArianeeWallets.methods.getMessage(data)
Get a message
Parameter
data
-object
: message request data objectmessageId
-number
: (optional) message id. Random if left emptyquery
-ConsolidatedCertificateRequest
(optional): object to request messageurl
-string
(optional): RPC server url to get messageforceRefresh
-boolean
(optional) : boolean to force refresh of message content
Result
promise
returns object
: The receipt of the blockchain transaction + keys :
certificateId
- number : certificate id linked to the messageissuer
- object :isIdentityVerified
- boolean : issuer identity verifiedisIdentityAuthentic
- boolean : issuer identity authenticimprint
- string : issuer imprintidentity
- string : issuer identity content
to
-string
: message recipient public addressmessageId
-number
: message idtimestamp
-timestamp
: message creation timestamp
Get my messages
ArianeeWallets.methods.getMyMessages(data)
Get my messages (related to my certificate)
Parameter
data
-object
: messages request data objectquery
-ConsolidatedCertificateRequest
(optional): object to request messageurl
-string
(optional): RPC server url to get message
Result
promise
returns array of object
:
certificateId
- number : certificate id linked to the messageissuer
- object :isIdentityVerified
- boolean : issuer identity verifiedisIdentityAuthentic
- boolean : issuer identity authenticimprint
- string : issuer imprintidentity
- string : issuer identity content
to
-string
: message recipient public addressmessageId
-number
: message idtimestamp
-timestamp
: message creation timestamp
Mark a message as read
ArianeeWallets.methods.markAsRead(messageId)
Mark a message as read an send Aria to owner and wallet reward address
Parameter
messageId
-number
: message id
Result
promise
returns ExtendedBoolean
:
isTrue
-boolean
: message mark as read (success / fail)code
: return code (message.markasread)'message
: return message (message was mark as read)
This method performs a blockchain transaction. It costs Gas
Set optin/optout for a specific sender + certificate id for current wallet
ArianeeWallets.methods.setMessageAuthorizationFor(certificateId, senderAddress, bool)
Change send right for a message sender
Parameter
certificateId
-number
: Arianee certificate idsenderAddress
-address
: Address of related senderbool
-boolean
: true or false. (apply flag)
Result
promise
returns object
: The receipt of the blockchain transaction
This method performs a blockchain transaction. It costs Gas
Example
// Change optin flag for a specific sender
wallet.methods.setMessageAuthorizationFor(12345,'0x5f89d20c4a88FC2479b08522d5adD0b605001E3e',false).then((data) => {
})
Read optin/optout for a specific certificate id
ArianeeWallets.methods.getMessageSenders({certificateId:CertificateId, query:ConsolidatedCertificateRequest})
Get optin status for a speficic certificateId based on current wallet
Parameter
parameters
-object
: certificateId and ConsolidatedCertificateRequest
Result
promise
returns object
: [address]: isIssuerAuthorized
Only return optin status of issuer only
Example
// Read optin flag for a specific sender
wallet.methods.getMessageSenders(12345).then((data) => {
})