Say I have a contract like so:
pragma solidity ^0.4.0;
contract SimpleStorage {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint) {
return storedData;
}
}
Kindly correct me if I'm wrong, but it is possible to change x
to, say, the value 500
, and the transaction that called set(500)
will be included in a block, which will make the change in the contract state. If another user calls the get
function after the block has been mined, it'll return 500
.
However, is it not the case that the block that contains the transaction that called set
will be orphaned in the future, and then future get
calls would return the previous value (e.g. 0
)? Or am I not understanding Ethereum properly?
If what I said is true, how could I be sure that the contract is returning a proper value? Do I need to store somewhere the transaction hash that invoked set
and then see how many confirmations it had? Or does a better solution exist?