I am trying to understand if there currently exists a method to send a message from a contract to another contract or a private address? What would the Solidity code for this look like? Perhaps events could be used for that?

Given that there is no privacy on the blockchain, the message will obviously be readable by everyone. So the only way I can think of doing it is by encrypting the message using the recipient's public key.

Some related questions are below, but they don't have answers to my question (and it looks like Whisper is not yet implemented):

1 Answer 1


You can't make an Ethereum contract start with plaintext and meaningfully encrypt a message, because all contract execution has to be verifiable by all the nodes in the network, so as you say everybody would also have to be able to see your plaintext.

If you want to send a message from one user of a contract to another user of the contract, the obvious thing to do is for the contract to manage an identifier for the user who wants to receive the message - say a PGP fingerprint - and the sender to use that to look up their PGP public key on a regular key server and use that to encrypt the message for them.

You probably don't want the encrypted message to actually transit the blockchain unless it's very small as it will cost gas, but you might want to use the blockchain to let the receiver know where to find the encrypted message - for example, store the encrypted message in IPFS, and have the sender update the contract to let the receiver know the hash of the document they've put on IPFS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.