Secure from cheating
To emphasize the security property (from cheating) of a smart contract, you can visualize the states changing, as shown in Figure 2.12:
Figure 2.12: The state of the x variable changing
Every time someone changes the value of x
, the transaction will be recorded on the blockchain. User 1 stores a value of 6
in x
and the information is recorded on the first block. Then, user 2 stores a value of 8
in x
, and the information is recorded on the second block. Lastly, user 1 stores a value of 2
in x
, and the information is recorded on the third block.
Of course, in the real world, the state changing is not conveniently put in sequential blocks. User 1 changes the value of x
, which is recorded on block 3, and then nothing happens for a long time. User 2 then changes the value of x
in block 1000
.
The important thing to note here is that the information that we get is not from only one smart contract. Let’s say three smart contracts...