4

I want to know who will help us execute when we call the functions in the smart contract. Is it the miner who put this transaction in the block?

Hope you can give me some help, Thanks!

0

2 Answers 2

3

In Ethereum 1.0, yes, it is a miner who includes the transaction in the blockchain. Read about Proof-of-work (Pow).

In Ethereum 2.0, it is a "validator" who includes the transaction in a block of a shard. Read about Proof-of-stake (PoS).

At the time of writing this answer, Ethereum 1.0 is still the "main" network. Ethereum 2.0 kicked off its Phase 0 on December 1, 2020, but it's going to take a while until it reaches the further stages.

1
  • 1
    Happy to help. You should also take a look at the ethereum.org docs. There are many useful articles in there. Commented Dec 6, 2020 at 10:23
2

When you submit a transaction to the network, it is distributed to all/most nodes of the network. Some of them are miners. Some of the miners pick your transaction to include it into the next block they intend to propose. In this process, they execute the transaction, including the smart contracts that are called. Then the miners try to find a suitable hash for their block. If they succeed, they broadcast the block to the network. Now all nodes in the network process the transactions in the block. If the block is accepted and becomes part of the chain, one may say that the transaction has been processed and the smart contracts have been executed.

If a new node joins the network, then it will process all transactions on the chain, in order to verify the chain and to compute the current state. In this course, also your transaction will be executed again.

5
  • Thanks for your answer. In your answer, you means that if a miner executes the smart contract, a result is generated and broadcast to the entire network. I want to know if this result may have been tampered with. If this is possible, how do other miners judge the authenticity of this result?
    – wei wang
    Commented Dec 6, 2020 at 10:45
  • No, the miner broadcasts only the block with the transaction, not the result. Every node computes the result itself. However, the miner decides about the order of transactions. Moreover, it can influence some of the block variables. It depends on the smart contract, whether it is sensitive to such manipulations
    – gernot
    Commented Dec 6, 2020 at 10:54
  • Thank you for your reply. Can it be understood like this: If a person calls a function of a smart contract, other nodes in the entire network will actually execute this function at the end.
    – wei wang
    Commented Dec 6, 2020 at 11:04
  • All nodes in the network perform all computations. In particular, the function call will be executed by all nodes, as soon as the block containing the transaction is added to the blockchain.
    – gernot
    Commented Dec 6, 2020 at 13:11
  • Thank you for your answer, it has benefited me a lot
    – wei wang
    Commented Dec 7, 2020 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.