0

When we execute a function on a smart contract, the transaction will be verified by all miners in the entire network before being written to the blockchain. I want to know no matter how complicated the smart contract function called by this transaction is or the function needs to pay some fees, do miners have to execute this function for verification?

For example, the function on this smart contract needs to pay token to call the payment interface on chainlink.

1 Answer 1

2

The transaction will be included in the blockchain the moment it is included in a block (at least from the miner's perspective), so it doesn't need to "wait" for other nodes to verify it first. If the miner is dishonest and the transaction result is not calculated correctly the block will be ignored by others.

Miners can choose which transactions to include in their block and they can even mine empty blocks if they want. Typically they simply include the transactions which provide the biggest benefit to them (the ones with the hightest gas price). This is the reason transactions with high gas price are processed faster.

So it is possible that a transaction is never mined by anyone. Also it is possible that nodes choose not to verify an incoming block and simply accept it, but this shouldn't be the case typically.

3
  • Thanks for your replay. I want to know what strategy the node chooses to decide whether to verify the current transaction? Can this strategy be provided by miners themselves?
    – wei wang
    Commented Dec 9, 2020 at 11:28
  • An excellent question. In theory no node "has to" verify blocks and there is no monetary incentive to do it. But, then you can't mine (because you don't know if the blocks are valid) and your node's data shouldn't be used by external users (because they don't know if the data is valid) - so why would you run a node in that case? Commented Dec 10, 2020 at 10:59
  • Thanks for your answer! I basically figured out this problem!
    – wei wang
    Commented Dec 10, 2020 at 11:17

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.