I'm working on designing an application that requires a contract to mediate a transaction between a seller and a buyer.
The buyer will initiate the game by paying the contract, the contract will then take the "goods" from the seller and send them to the buyer, and finally send the money to the seller.
The "goods" in this case are just some data (that is NOT stored on the chain, and is generated off-chain by the seller.)
My question then is, how do I go from this to a working solidity contract?
My current design (my knowledge of solidity is very limited):
There could be a contract function say i_need_to_buy() that the user will call thereby paying some gas etc.
The contract will emit an event seller_send_goods_now() sending the buyer's public key.
The seller will be waiting for this event (via web3.watch perhaps?) It'll do some off-chain computation (say encrypting the data with the buyer's public key - so only she can open it.)
The seller will then call another contract function send_goods_back() sending the encrypted data to the contract.
The contract will emit a new event goods_received() forwarding the data (essentially to everyone.)
The buyer will be waiting for this event and has now received the goods. She decrypts the data and thanks Vitalik Buterin.
If seller doesn't send the "goods" the contract could just refund the money, right?
Is the design good enough? What would you change?