Skip to content

mailchain/mailchain-sdk-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailchain SDK monorepo

Mailchain is a messaging protocol that lets users communicate across protocols. Using Mailchain you can send messages to any blockchain address on different protocols.

For full usage examples view the developer docs.

Repo layout

Contains the packages directly related to the Mailchain SDK.

Example

Send your first message

Try sending your first message a message to 0xbb56FbD7A2caC3e4C17936027102344127b7a112@ethereum.mailchain.com, that's us at Mailchain, we own the private key for 0xbb56FbD7A2caC3e4C17936027102344127b7a112.

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

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

const mailchain = Mailchain.fromSecretRecoveryPhrase(secretRecoveryPhrase);

const { data, error } = await mailchain.sendMail({
	from: `[email protected]`, // sender address
	to: [`0xbb56FbD7A2caC3e4C17936027102344127b7a112@ethereum.mailchain.com`], // list of recipients (blockchain or mailchain addresses)
	subject: 'My first message', // subject line
	content: {
		text: 'Hello Mailchain 👋', // plain text body
		html: '<p>Hello Mailchain 👋</p>', // html body
	},
});

if (error) {
	// handle error
	console.warn('Mailchain error', error);
	return;
}
// handle success send mail result
console.log(data);

You can send a message to yourself your username@mailchain if you've registered an ethereum address you can send a message to it [email protected], or try sending a message to 0xbb56FbD7A2caC3e4C17936027102344127b7a112@ethereum.mailchain.com, that's us at Mailchain, we own the private key for 0xbb56FbD7A2caC3e4C17936027102344127b7a112.