Request to Build - a Graph based email system

Send a message to another user, on chain.

TL;DR

  1. Encrypt message to receiver using their public key
  2. Create a transaction on main chain that emits an event with the receiver’s address and the encrypted message
  3. Create a subgraph and index these events
  4. Display the encrypted messages
  5. When the user opens the message, decrypt and display message

Encrypt using public key

For this you need the public key of the user. You might not always have it.

To get the public key, you need to have access to atleast 1 transaction made by this user.

To register to receive encrypted messages, a user must make a register transaction to your smart contract on chain. Then, using this transaction, extract the public key and store it on chain.

The typed message should be encrypted using Metamask.

Refer :

Emit message

If public key is available, encrypt it. Else send an un-encrypted message.

To send a message put the encrypted or unencrypted message on a blob in IPFS.

Make a transaction to your smart contract that emits an event with the to address and ipfs hash .

Create a subgraph

Index these events using TheGraph protocol.

Make it query-able “get all messages for a given receiver”.

List messages

When a user opens their inbox show the list of all the messages they’ve received by querying TheGraph

Show only sender name (ens) or address and send time.

Open message

When the user taps on the message, fetch the file from ipfs. If it is encrypted decrypt using Metamask.

Bounty!

If you build this on or before 10th January 2022, I pay 1 ETH.

Subscribe to Madhavan Malolan
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.