How can I utilise (perhaps automate) a smart contract to deliver some encrypted data from A to B, based on the pre-requisite that A fulfills B's requirements. Would I need an oracle for this type of interaction and if so, how could such communication successfully be rolled out?

  • It's not quite clear what you're asking. Please provide more information. – ivicaa Jan 25 '19 at 20:30
  • 1
    Let's try like this. Imagine I have some wrapped up purchasable data for sale for a certain price. The buyer must meet the price condition to be able to buy the wrapped up data. Now the wrapped data should not be publicly visible on the blockchain, unlike the action/purchase itself. In addition, what if someone wants to buy x amount every t hours, would an oracle be required for communication or would a script do? – NowsyMe Jan 26 '19 at 0:20

You can model the payment action in the blockchain and let your download server monitor the contract events. If an address A purchased the data, the owner of address A can send a signed http request to your download server (signed with the private key of the address A) to prove that the download request comes from the owner of the private key of address a. Having the signature, your download server can check the purchase event on the blockchain to verify if A has purchased the data or not and serve the file accordingly.

This will also work if you need x amount every t hours.


contract DigitalDownload {


    event DigitalDownloadPurchasedEvent(uint time, address purchaser)


    function purchaseDigitalDownload() public payable {
        require(msg.value == PRICE);

        emit DigitalDownloadPurchasedEvent(now, msg.sender);

buyer --- > BC: purchaseService transaction

buyer --- signed http req ---> Server: download content
...the request is signed with the private key of the msg.sender...
...server makes ecrecover on the signature and recovers the public ethereum address of the request sender...

server ---> BC: check `DigitalDownloadPurchasedEvent` exists for the address recovered from the signature and serve the file if yes.
  • Would this require any on-chain identity uniquification of the purchase other than the public key, for the download server to prove the pK of address A? – NowsyMe Jan 26 '19 at 10:45
  • I've added an example to the answer. It depends on your concrete usecase, but in the simple case, you do not need any identity check in the smart contract. Everybody with an ethereum wallet can purchase your download service and then send a signed download request to the server to get the file. The existance of the Purchase event onchain is the autorization for the server to serve the download. – ivicaa Jan 26 '19 at 10:58
  • Thank you for for challenging my train of thought @ivicaa – NowsyMe Jan 26 '19 at 12:05
  • In this case MetaMask and web3 could help. I guess users and/or developers should never send or receive private keys directly. – dkb Jan 26 '19 at 13:50
  • The private key is not sent, it is used to sign a bc transaction or a server http request. – ivicaa Jan 26 '19 at 13:53

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