2

In my limited understanding of smart contracts, I've read that every node on the Ethereum network must execute a smart contract to come to consensus. I'm guessing that not all these nodes execute the contract at the same time. If this assumption is true, then what happens if a smart contracts depends on data that fluctuates, e.g. the price of a crypto/currency? If those execute the contract at different times and the value of the currency is different at each of those times, how is consensus reached?

2

In summary, this is a limitation of smart contracts on Ethereum. You can't write a contract that depends on an external input like that.

Everything needs to independently verifiable by every node, now and in the future. No external input meets that criteria.

Of course, it is still useful to have external input, so what is the solution?

A smart contract can verify that an external witness (externally owned account) attested that a given input was a given value at a given point in time. This signed transaction (with data) will become a fact of the blockchain that all nodes will be able to confirm.

Once this "Oracle" pattern is understood, it becomes less of an engineering problem and more of a business process problem. Who or what will function as the Oracle, where will get its authority and why should participants trust its input implicitly?

This may help: How do oracle services work under the hood?

Hope it helps.

  • Yes but what will happen if someone does it? Implement contract A and contract B that depends on the state of A. Send transactions to both A and B from different origins. – rustyx Jun 13 '18 at 20:16
  • The blockchain gives you a well-ordered set of transactions signed by externally owned accounts. There's no way to create an internal logical mix-up from the EVM perspective but it's important to think things through. In your example, either B depends on A and ignores other opinions, or B depends on other opinions and ignores A. It's important to have very high precision in contract design or possibly it won't prove anything useful. – Rob Hitchens - B9lab Jun 13 '18 at 20:50
  • Never mind - the order is defined by a single miner at the moment of sealing a new block. Other nodes simply replay and validate the already chosen, ordered transactions. – rustyx Jun 13 '18 at 21:17

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.