Send a message to another user, on chain.
TL;DR
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 :
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
.
Index these events using TheGraph protocol.
Make it query-able “get all messages for a given receiver”.
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.
When the user taps on the message, fetch the file from ipfs. If it is encrypted decrypt using Metamask.
If you build this on or before 10th January 2022, I pay 1 ETH.