21 ms·
Ask HN: How Ethereum (smart contract) works?
Hello,
I have been looking at smart contract and ethereum today. I have very good understanding of bitcoin and some knowledge about smart contract.
but there are some details I don't understand and I wan't able to find good explanation.
I know that as part of block verification, everyone on the ethereum network needs to run all the triggered contract codes and verify the execution with others'.
how does this work? how can you verify other people's execution of a program? does it only look at the output of a program? or the storage change of that program?
for example, a contract transfers $10 to a person A. how do I check if this contract has been executed or not by another person B? if it only looks at the output of the program or storage change, he can easily fake the result, right?
also, since the contract code runs on everyone's computer, how to prevent race condition and control execution times?
for example, I wrote a contract to transfer $10 to a person as a penalty, if I lost his book. How can I make sure this contract will only be executed once, as I don't want multiple $10 being transferred to that person?
Thanks.
- chrispeel 10y agoMany of your questions would equally apply to Bitcoin. For example, your question about transferring $10 to person A applies to Bitcoin as well. Ethereum uses a blockchain, as pioneered by Bitcoin to ensure that transactions are not spent twice. For your last example, you might put the $10 in escrow, with a key held by you, one by the book owner, and one by a trusted third party. If you lose the book, if the third party and book owner agree, your money is released from escrow.