Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ERC: address-to-address messaging system protocol #802
The following describes the details of the smart-contract based messaging system which aims to allow Ethereum users to directly contact the address owner without having to know who hi (she) is.
Ethereum lacks a central messaging system that will allow to contact an address owner directly. You can send him a transaction with ASCII message attached as
This service is necessary in some circumstances, for example:
Basic address-to-address messaging smart-contract.
This is a simple smart-contract that stores messages mapped to addresses by id and a mapping that represents the last message id for each address. Last message id increases for the receiver address when this address receives a new message (there is no message at
There is no possibility to edit, change, delete messages. This contract is not a messenger or a chat. This contract is an emergency way to contact an owner of a certain address when there is no possibility to contact him off-chain. As the result, editing and deleting messages has no reason because it will still be available via history of transactions.
Basically, there is no way to encrypt message on-chain because there is no way to hide an input call data. As a result, there is an additional field for attaching a public asymmetric encryption key. If the owner of a certain address has a desire to allow someone to contact him privately, then he can publish his public key at this contract and describe what type of key he has published at the "Key type" variable (for example
function sendMessage(address _to, string _text)
Delivers a string message to
function lastIndex(address _owner) constant returns (uint256)
Returns an index of the last message for the
NOTE: This means that there are messages at
function getLastMessage(address _who) constant returns (address _from, string _text)
Returns the last message for the
NOTE: Message is actually at
function getMessageByIndex(address _who, uint256 _index) constant returns (address, string)
Returns the message for
function getPublicKey(address _who) constant returns (string _key, string _key_type)
Returns a public key of the
function setPublicKey(string _key, string _type)
Sets a public key and a description of key type for the sender address.
event Message(address indexed _sender, address indexed _receiver, uint256 _time, string message)
Triggered when a new message is sent. This event logs
event PublicKeyUpdated(address indexed _sender, string _key, string _keytype)
Triggered when a customer updates a public key of an address or sets it first time. This event logs a new public key and key type to make it easier to recognize which encryption algorithm should be used with this key.
Obviously, this contract can not guarantee that an owner of the address will receive a message. It requires to be supported by UIs. It is likely that an owner of a certain address will see a message if MyEtherWallet, MetaMask or Mist will display messages somehow (for example a certain number of last messages).
Also, it makes sense to standardize possible public key types. Ideally, UI should have a button "Send message to address" and "Send encrypted message to address" and distinguish public key, key type and then encrypt message automatically.
Looks very useful. Just the other day I was thinking about something similar, given how many issues I've seen of people mistakenly sending tokens, or even the case you mention of a contract being hacked and having no way to communicate with the perp.
Have you thought about firing an Event when a message is sent? It would make it easier to read all messages for a particular contract and even filter them by date or sender.
We could possibly enhance this a little. If someone sends a transaction it exposes their public key. A blockchain explorer could act as an oracle in this case.
@3esmit the expense doesn't really matter here; use public key cryptography to organize conversation off-chain. This serves the (particularly useful) purpose of a central location to check for messages that you want to send to an address, without having to know anything about someone besides their address.
@Dexaran I would also include that this is also useful for contacting owners of ENS domains.
I like this and could contribute time towards building a canonical interface for this contract.
There is one concern that I'd like to discuss: crosschain interoperability.
Request for comment: cross chain interoperability
The whole Ethereum ecosystem lacks an address to address central messaging system. It is not a local problem of Ethereum, it is a bit more global. Currently, there are some "Ethereum-compatible" chains: ETC, PIRL, UBQ, EXP, MusiCoin (and probably RootStock) and they all need to solve the same problem.
NOTE: I've said Ethereum-compatible chains since they all utilize the same address schemes. The owner of
To be honest, I don't see any reason to deploy exactly the same service on each chain separately. This is not to benefit of anyone. I think that the best idea is to deploy the service on one chain and then consider it a core part of the overall messaging system.
A UI that have access to multiple nodes (for example MyEtherWallet) can connect to the core-node (node of the network that will be used to deploy this service contract) and look for messages. If the message for the address is found at the core-network, then the UI should display it to the user. It doesn't matter if the user is currently on the core-network or any of the alternative Ethereum-compatible chains.
This approach has some advantages:
I'd like to receive more feedback and any thoughts about this.
Message system in use: ethereumproject/ECIPs#85 (comment)
Here is a reference implementation of the described Message System at CLassicEtherWallet.
Interchain Address-To-Address messaging contract is currently deployed on Ethereum CLassic chain at 0x6A77417FFeef35ae6fe2E9d6562992bABA47a676 address.
It is an open-source contract and it is licensed under GPLv3. Source codes could be found here: https://github.com/EthereumCommonwealth/Address-to-Address-messaging
The described messaging system allows:
Sending a message.
Watching your messages.
NOTE: This is an emergency message system! Not an on-chain chatroom.
Every symbol that you broadcast to the network will cost you gas. This is not an on-chain chat! This is only an emergency system that allows you to contact an owner of a certain address if there is no way to contact him off-chain. For example if you accidentally sent a number of funds into someone elses address or if you want to interview TheDAO hacker.