Mail

Class that handles sending, retrieving and listening for events related to mail on-chain storage.

Usage

Below is a minimal example of how to initialize Mail (with no optional parameters). It's highly recommended to also use your own appId.

import { Mail } from '@4thtech-sdk/ethereum';

const mail = new Mail({
  walletClient,
  remoteStorageProvider,
});

Parameters

config

  • Type MailConfig

The configuration object required to initialize the mail client.

config.walletClient

  • Type WalletClient

An instance of the wallet client that takes care of sending Ethereum transactions.

config.remoteStorageProvider

  • Type RemoteStorageProvider

An instance of the remote storage provider for storing and retrieving mail-related data stored off-chain such as metadata and attachments.

config.appId (Optional)

  • Type AppId
  • Default 0x0000000000000000000000000000000000000000000000000000000000000000

A unique identifier for your application.

Application ID is used to effectively store and retrieve mails based on ID. Without an assigned App ID, it defaults to "zero". When multiple apps uses the same ID, all mails are shared in all those apps. Problem can appear if some of those apps uses encryption or remote storage provider that is not supported by your app. Those mails then can't be retrieved/decrypted.

On top of that, if you register your own app, you can set up an integrator fee which will be charged on every sent mail.

const mail = new Mail({
  walletClient,
  remoteStorageProvider,
  appId,
});

config.encryptionHandler (Optional)

  • Type EncryptionHandler

The handler used for decrypting mails.

To manage encrypted emails effectively, ensure you provide a EncryptionHandler instance. This instance must include all encryption types used by your app. Without this, encrypted emails cannot be decrypted.

const mail = new Mail({
  walletClient,
  remoteStorageProvider,
  encryptionHandler,
});
Previous
Ethereum