Mailchain users can send messages to any Ethereum account address. This section details how the Ethereum implementation of the Message Flow is achieved.
Mailchain supports all the common Ethereum networks
To send an encrypted message, a public key is required. Mailchain uses the public key associated with an account address to encrypt the data, and if specified by the envelope, the message contents. This ensures the recipient is also the owner of the private key and only they can decrypt data. The public key finder searches for transactions sent by the recipient address and extracts the public key.
Ethereum transactions are used to send a message.
Transactions contain a
data field that stores the envelope. Bytes can be stored in the
data field and must be hexadecimal encoded, prefixed with
0x as per the Ethereum specification. Data stored in a transaction must follow the Mailchain standard encoding format:
Required Ethereum transaction data prefix
"mailchain" encoded as hexadecimal
Envelope encoded as hexadecimal
An example of transaction data for a Mailchain message sent on Ethereum is as follows:
The same transaction and data can be viewed on here on Etherscan.
To send a message these Ethereum transaction fields must be specified.
Sequential number that represents the number of transactions the sender account has made on the network. Added by the client, based on last nonce.
Execution fee for sending the message. Added by the client, based on network gas price.
Maximum gas used for sending the transaction. Mailchain messages uses ~30,000 GAS approx 1.5x the cost of a basic transaction. Added by the client, based on required gas.
Address of the recipient. Added by the client, based on recipient address in message.
Set to send zero value transactions by default
Once the transaction fields have been populated, it must be signed using the sender private key. The signed transaction bytes can then be transmitted to the ethereum network over JSON-RPC using the eth_sendrawtransaction method.
To read Mailchain messages for a specific address, transactions sent to that address need to be identified. Ethereum does not natively support an address index or similar functionality that identifies all transactions sent to or from an specific address. Third parties have API's that provide this functionality, including Etherscan.io.