Adding secure & private web3 email between .lens users

Adding secure & private web3 email between .lens users

March 1, 2023

Developers, get ready to elevate your web3-native communication game! The Lens Protocol and Mailchain integration allows you to send and receive web3-native email via your .lens profiles bringing a secure and private communication method to your applications. In this blog post, we’ll dive into the benefits of this integration and show you how to use it.

With Mailchain’s multi-protocol solution, developers can communicate through web3 email without revealing private keys or any other personal information. This integration provides functionality to your application allowing your users to get important information about their content, publications, contact others in their community, and receive information from projects they care about. The Lens and Mailchain integration provides a simple and seamless way for developers to interact with their communities and build decentralized applications.

Get started in 17 lines

Using Mailchain, you can send a message to any blockchain address. Only the owner of the address will be able to receive and read the message. To send your first message, follow these simple steps:

Adding Mailchain to your application is easy. Mailchain's SDK makes interacting with the Mailchain protocol simple. To add Mailchain's SDK to your application install via your package manager of choice:

npm install @mailchain/sdk

yarn add @mailchain/sdk

Import the Mailchain SDK

The first step is to import the Mailchain SDK in your project. You can do this by adding the following command:

import { Mailchain } from '@mailchain/sdk';

Add your Secret Recovery Phrase

To use the Mailchain SDK, you need to set up your Mailchain account. You can do this by creating a secret recovery phrase, which is a 25-word mnemonic phrase.

const secretRecoveryPhrase = process.env.SECRET_RECOVERY_PHRASE!; // 24 word mnemonicPhrase

Create a Mailchain instance

Once you have set up your Mailchain account, you can create a Mailchain instance using your secret recovery phrase.

const mailchain = Mailchain.fromSecretRecoveryPhrase(secretRecoveryPhrase);

Send your first message

Now that you have set up your Mailchain instance, you can send your first message. In this example, we’ll send a message to a Lens Protocol address.

const result = await mailchain.sendMail({
    from: `mailchain.lens`, // sender address
    to: [`myfrenz.lens`], // list of recipients (.lens or mailchain addresses)
    subject: 'Mailchain now supports .lens profiles 🌿', // subject line
    content: {
        text: 'Hello Frenz πŸ‘‹', // plain text body
        html: '

Hello Frenz πŸ‘‹

', // html body }, }); console.log(result);

Check your sent folder

After the message is successfully sent you will be able to see it in your sent folder. The recipient will see it in their inbox.

For more information about how to use the SDK, check out our docs here: https://docs.mailchain.com/developer/

Easily bring secure, web3-native communication to your app

Using the Lens and Mailchain integration provides developers with a simple and seamless way to interact with their communities and build decentralized applications. By using the Mailchain SDK and following the steps outlined above, developers can easily send and receive web3-native email via their .lens profiles. This also extends to other web3 domains such as .eth, .nft, .dao, etc.

We’re excited to see how developers will use this integration to build innovative and impactful decentralized applications.

Meet the writer

Tom is a web3 Marketer and Growth Hacker. He’s been helping both brands and creators launch their own web3 ideas and experiences since 2019, mostly focusing on blockchain gaming and the Metaverse he brings a down-to-earth and open-minded perspective on these huge trends.
Tom Sargent
Founder of ExpensiveJPEG, Ex-Landvault, and now Marketing here at Mailchain.