[Ethereum] how to deal with race condition and execution times of a contract

contract-developmentethereum-classic

I'm a ethereum beginner. I can't understand some of its concept.

for example, a contract should be executed by everyone on the network as a way to verify a block.

what about synchronization among all executions of the same program?

suppose I write a program to transfer $10 from my account to a friends as a penalty if I lost his book.

in this case, I only want one $10 transferred. but if my contract will be executed multiple times, then how to prevent multiple transfer?

Best Answer

You are mixing 2 layers of abstraction:

  • the distributed ledger, on which multiple machines do things many times to reach a consensus
  • the Ethereum Virtual Machine (EVM), which is an expression of the consensus, and which behaves like a single process computer.

So since your program computes in the EVM, it is unaware of the distributed ledger and the many machines involved.

Related Topic