Algorand (under development)

Mailchain users can send messages to any Algorand account address. This section details how the Algorand implementation of the Message Flow is achieved.

Networks

Mailchain supports all the public Algorand networks

Network

Status

Mainnet

Pending

BetaNet

Pending

TestNet

Pending

Public Key Finder

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 returns the public key for a recipient public address.

The public key for an account address can be calculated from the public address by converting it from its Base32 encoded representation to Base58 and removing the 4-byte checksum.

Sender

Algorand transactions are used to send a message.

Envelope

Transactions contain a note field that stores the envelope. Bytes can be stored in the note field and can be any data up to 1000 bytes. Data stored in a transaction must follow the Mailchain standard encoding format:[protocol-prefix]+[mailchain-prefix]+[envelope]. This data will be encoded to Base64 when transmitted.

Field

Example

Notes

protocol-prefix

None

Transaction data prefix is not required for Algorand.

mailchain-identifier

bWFpbGNoYWlu

"mailchain" encoded as base64

envelope

AQqCAS7hDFkCTINtfKEkcLWsdGcwAhJ93trbxvxDdajAhrZQBg7eGZ9gOhWLx4hKkD6t+Xot0PvmmsgcIWgw+U5WuEfZJLUafYInyAcUIZ5oIaUbx8upIvKRpHvf/innw/Z62Qj/N3v8wLYDAH6tS/2H/wrMJyUoygPWOB5tDh4sXf0k1SE

Envelope encoded as hexadecimal

An example of a transaction note field for a Mailchain message sent on Algorand is as follows:

bWFpbGNoYWluAQqCAS7hDFkCTINtfKEkcLWsdGcwAhJ93trbxvxDdajAhrZQBg7eGZ9gOhWLx4hKkD6t+Xot0PvmmsgcIWgw+U5WuEfZJLUafYInyAcUIZ5oIaUbx8upIvKRpHvf/innw/Z62Qj/N3v8wLYDAH6tS/2H/wrMJyUoygPWOB5tDh4sXf0k1SE=

The same transaction and data can be viewed here on Algoexplorer.

Transaction Fields

To send a message the following Algorand transaction fields must be specified.

Field

Codec

Type

Example

Notes

Fee

fee

uint64

1000

Paid by the sender to the FeeSink to prevent denial-of-service. The minimum fee on Algorand is currently 1000 microAlgos.

FirstValid

fv

uint64

6000000

The first round for when the transaction is valid. If the transaction is sent prior to this round it will be rejected by the network.

LastValid

lv

uint64

6001000

The ending round for which the transaction is valid. After this round, the transaction will be rejected by the network.

GenesisHash

gh

[32]byte

"mainnet-v1.0"

The hash of the genesis block for the network for which the transaction is valid. See Algorand developer documentation for details of the genesis hash for MainNet, TestNet, and BetaNet.

Sender

snd

Address

(string)

G2GTKMEEEEZH5TFUDYZMWWGXZLO3Z7765CR52ZXBBNCCMNPDYM3ZII7CSI

The address of the account that sends the messages and pays the fee.

Added by the client, based on sender address in message.

Receiver

rcv

Address

(string)

UWH6MCLMZSD2UYWTJVKFKX6JMTX2TGXAOYPUBNHFFQFBBVJULXJXZJNPBU

The address of the account that receives the message.

Added by the client, based on recipient address in message.

TxType

type

string

"pay"

Specifies the type of Algorand transaction. Mailchain uses a zero-value payment transaction by default.

Note

note

[]byte

bWFpbGNoYWluAQqCAS7hDFkCTINtfKEkcLWsdGcwAhJ93trbxvxDdajAhrZQBg7eGZ9gOhWLx4hKkD6t+Xot0PvmmsgcIWgw+U5WuEfZJLUafYInyAcUIZ5oIaUbx8upIvKRpHvf/innw/Z62Qj/N3v8wLYDAH6tS/2H/wrMJyUoygPWOB5tDh4sXf0k1SE=

Envelope data

Amount

amt

uint64

0

The total amount to be sent in microAlgos.

Mailchain sets this to 0 (zero).

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 Algorand network via the Algorand network API endpoint using the POST /v2/transactions method.

Receiver

To read Mailchain messages for a specific address, transactions sent to that address need to be identified. The Algorand indexer natively supports an address index to identify all transactions sent to a specific address.