1

Since when a transaction is done, every node in the blockchain runs the smart contract in their machines, what if the smart contract is calling an oracle to get a random value? Shouldn't it return different output for every node? How does Ethereum handle it?

0

It's the other way around: the oracle puts data in the smart contract. Once the data is there all the nodes will see the same value.

For your scenario - yes, the number is random. It is generated by the oracle. But once it is stored in the smart contract, all the nodes will run their code against the same value.

This article describes some techniques you can use to build your own oracle. Even if you don't intend to build one yourself, it's a good read, because

| improve this answer | |

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.