I read the following E-SO post and also several threads on Ethereum/Solidity forums regarding smart contracts and external servers (anything involving a socket):

Why can't contracts make API calls?

I understand that the idea is to maintain deterministic code and accessing an external server breaks that covenant. I also understand that it creates a security or logistics problem when it comes to smart contract code making socket calls.

Can someone tell me then how you would handle a scenario like the following?

Suppose a smart contract is involved with the transfer of an asset like a real estate deed or title, held in escrow until the conditions of the smart contract are fulfilled.

Suppose midway through the contract, it is discovered that the land deed is fraudulent. What I can't fathom is how to write a smart contract that doesn't interact with an external server, that can check for that invalidation condition mid-execution before fulfilling the contract?

I've heard people mention Oracles but I still haven't seen a document that describes a concrete way to handle the very real life circumstance I just described. Said more abstractly, any real life circumstance that occurs during the execution of a smart contract that essentially invalidates the transaction. Techniques anyone?

1 Answer 1


The contract itself can only use data of blockchain + transaction. Completely deterministic. However, you can have special trusted address in your contract, which will be allowed to put data into the contract.

So, some trusted off-chain process checks any conditions it wants(fraud, in your example), sends this data to contract on chain, and then it it processed by contract. People named such process Oracle.

From developer's perspective it looks like a new method in contract, which accepts some data:

function takeOracleData(uint newImportantExternalValue) {
    require(msg.sender == trustedOracleAddress);
    storedImportantExternalValue = newImportantExternalValue;

And then you just use stored value as some real world data. Now you need to call takeOracleData regularly. So you just make a process(python script, for example), which gets new data and calls the function every 10 minutes. That's all.

Here is an example of Oracle, watching new contract events.

  • I upvoted your answer but this is the point I always get stuck at when I ask this question and so far have not been able to get a good answer. I really need a code sample or document that shows me how a smart contract interacts with a trusted off-chain process. Do you have a link for something like that? Dec 16, 2017 at 13:16
  • OK, I don't have a link, so I just extended my answer. Feel free to ask about anything. Dec 16, 2017 at 14:54
  • Thank you. Accepted your answer. If you have any docs/web pages that deal heavily with the message "sender" field and how to program it that would be great. Adding it to your answer would help others too I'm sure. Dec 16, 2017 at 15:21
  • 1
    Well. That's just infinite loop calling contract method. Or looking for new events of contract. Here is an example medium.com/@mustwin/… Dec 16, 2017 at 15:29
  • excellent, thanks. If you do Ethereum programming consultation for a reasonable fee let me know. If so, follow me on Twitter (search for "roschler") and we can follow-up in DM. Dec 16, 2017 at 15:57

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.