7

As per the basic rules of blockchains believe it is mentioned that no service call from the smart contract should be made where the result is non deterministic.

What I understand is if the result is non deterministic in that case, when the transaction will be executed in different nodes it will not be possible to reach consensus as everyone may get different results.

When a new node is added it is expected to first sync to get the whole distributed ledger downloaded.

Believe every new node added on the blockchain network verifies all the previously generated transactions. So in this case it will invoke this external service as well to verify the result and based on the output will behave accordingly.

But found using Oraclize one can invoke external services from smart contract. So if the above assumption is correct then how come it is feasible to invoke external services or are they invoked for specific scenarios only

6

Miners never make external calls on behalf of your contracts. Oracles are done by a user (or machine, of course) sending a tx into the Oracle contract putting the data there. Your contract then reads the data from the Oracle contract, not from the off-blockchain world. The data from the external source may be non-deterministic, but once it's on the blockchain, it's been determined.

  • Question is will this same transaction be invoked from every node to verify the result. If so then it makes me believe that it will invoke the service for each node. Or are you saying that the invocation of external service will be done only once? – Susmit Nov 11 '17 at 3:53
  • I'm saying that there is never an invocation of an external service on the blockchain or by a node. Contracts can not call outside of the blockchain. Oracles are services off-chain that send transactions to contracts in the blockchain to store the data on the blockchain. Only after the data is on the blockchain can you access the data. Aka I would query some service from my computer, get the result, then send a transaction to the blockchain to store the data. I am the oracle, and I'm putting the data in an oracle contract. You then access the data from the oracle contract. – flygoing Nov 12 '17 at 15:24
  • So lets say I need to check the state of status which is actually updated by an external service and based on that will be applying some logic in my contract. Now are you saying that I should invoke that service external to blockchain, fetch the status value and store the result in blockchain via a transaction. The contract used to store the value becomes the Oracle. Once done then the main contract will invoke this Oracle contract to check the the status value? But if you really mean that then what feature provided by Oracalize library. – Susmit Nov 12 '17 at 16:59
  • 1
    Mostly correct, but you're still mixing up the ordering of the external query/2nd tx. After oracalize picks up your request for a query, it does the call to a URL to do your request. This only ever happens once per query. After the query, Oraclize creates a tx to call your __callback function. – flygoing Nov 13 '17 at 12:10
  • 2
    Correct. Oraclize is a company completely separate from the Ethereum foundation that runs this service, and it won't exist on private blockchains. Yes, you would have to create a similar framework for a private blockchain to get the same functionality. – flygoing Nov 13 '17 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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