Create & Manage Message
Methods related to messages management.
Get available dMessage ID
Method:
creator.getAvailableMessageId()
Response: promise
returns number
corresponding to the messageId
.
Check if a dMessage ID is available
Method:
creator.isMessageIdAvailable(id)
Parameter | Mandatory | Type | Description |
---|---|---|---|
id | ✅ | String | dMessage identification number to be checked. |
Response: promise
returns boolean
:
true
: dMessage ID available.false
: dMessage ID already used.
Create dMessage
Create and send a dMessage and store its content on the Arianee Privacy Gateway.
- Your wallet must own at least 1
message
credit. The credit is spent when the message is read.- The dMessage requires to have an identity URI.
Method:
creator.createAndStoreMessage(data, overrideTransaction?:NonPayableOverrides)
Parameter | Mandatory | Type | Description |
---|---|---|---|
data → smartAssetId | ✅ | String | Recipient NFT of the message. |
data → uri | ✅ | String | Message uri. Mandatory with imprint if no content. |
data → imprint | ✅ | String | Imprint of the message. Mandatory with uri if no content. |
data → content | ✅ | Object | Content mandatory if no uri and imprint. |
data → messageId | ❌ | String | dMessage identification number. If not defined, a random one is generated. |
overrrides | ❌ | gasPrice , gasLimit , maxFeePerGas , maxPriorityPerGas | Allows you to override the gas/gasprice part to be able to move transactions through more quickly if needed. |
Example:
const core = Core.fromRandom();
const creator = new Creator({
creatorAddress: '', // address that will be rewarded for creator action
core: core,
});
const isConnected = await creator.connect('polygon');
if (isConnected) {
await creator.buyCredit(CreditType.message, 1);
await creator.messages.createAndStoreMessage({
smartAssetId: 12343,
messageId: 1232143,
content: {},
}); /
Response:
- The dMessage is created and received in the recipient wallet.
- An error may occur.
Error type | Description |
---|---|
InsufficientMessageCreditsError | The core wallet address does not have enough message credits. |
UnavailableMessageIdError | The messageId is not available. |
NoIdentityError | The core wallet address does not have an Identity URI. |
ArianeePrivacyGatewayError | Error while interacting with the Arianee Privacy Gateway. |
Create dMessage without storing content
Method for test purposes.
Your wallet must own at least 1
message
credit. The credit is spent when the message is read.
Method:
creator.createMessage(CreateAndStoreEventParameters, overrideTransaction?:NonPayableOverrides)
Parameter | Mandatory | Type | Description |
---|---|---|---|
smartAssetId | ✅ | String | Recipient NFT of the message. |
imprint | ✅ | String | Imprint of the message. Mandatory with uri if no content. |
messageId | ❌ | String | dMessage identification number. If not defined, a random one is generated. |
overrrides | ❌ | gasPrice , gasLimit , maxFeePerGas , maxPriorityPerGas | Allows you to override the gas/gasprice part to be able to move transactions through more quickly if needed. |
Response:
- The dMessage is created and received in the recipient wallet.
- An error may occur.
Error type | Description |
---|---|
InsufficientMessageCreditsError | The core wallet address does not have enough message credits. |
UnavailableMessageIdError | The messageId is not available. |
Updated about 1 year ago