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)
ParameterMandatoryTypeDescription
idStringdMessage 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)
ParameterMandatoryTypeDescription
datasmartAssetIdStringRecipient NFT of the message.
datauriStringMessage uri. Mandatory with imprint if no content.
dataimprintStringImprint of the message. Mandatory with uri if no content.
datacontentObjectContent mandatory if no uri and imprint.
datamessageIdStringdMessage identification number. If not defined, a random one is generated.
overrridesgasPrice, gasLimit, maxFeePerGas, maxPriorityPerGasAllows 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 typeDescription
InsufficientMessageCreditsErrorThe core wallet address does not have enough message credits.
UnavailableMessageIdErrorThe messageId is not available.
NoIdentityErrorThe core wallet address does not have an Identity URI.
ArianeePrivacyGatewayErrorError 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)
ParameterMandatoryTypeDescription
smartAssetIdStringRecipient NFT of the message.
imprintStringImprint of the message. Mandatory with uri if no content.
messageIdStringdMessage identification number. If not defined, a random one is generated.
overrridesgasPrice, gasLimit, maxFeePerGas, maxPriorityPerGasAllows 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 typeDescription
InsufficientMessageCreditsErrorThe core wallet address does not have enough message credits.
UnavailableMessageIdErrorThe messageId is not available.