I read here -- On which node smart contract get executed taht once your smart contract gets incorporated into the Ethereum network, every node on the network will execute that contract (done to prevent someone from cheating and claiming it required more gas than it did). However if everyone is executing the contract, who is receiving the transaction fees? Please let me know what fundamental things I'm missing here.
-
The miner that finds the block collects the fees. See also ethereum.stackexchange.com/questions/38992/… , ethereum.stackexchange.com/questions/36686/… , and ethereum.stackexchange.com/questions/13201/…– lungjCommented Feb 25, 2018 at 21:23
-
@lungj, I'm not asking about who mines the block but rather why do all nodes in the Ethereum network have to execute the smart contract? It seems like a waste of resources. If I ran a node and I wasn't getting paid for executing a smart contract, why would I want to waste power and money doing it?– DaveCommented Feb 26, 2018 at 23:52
-
@Dave - If you were running a full node, why do you think you would be running it? Presumably you have a reason to do so, otherwise you'd be relying on someone else's node for access to the network. If you have a reason for running it, then you also have a reason for ensuring the blocks you receive are valid. If you were working with invalid blocks, then any assumptions you make about the data integrity on your node are also invalid. So you need to execute the transactions to ensure they equate to valid state transitions.– Richard HorrocksCommented Feb 28, 2018 at 19:44
Add a comment
|
2 Answers
The miner who successfully mines the block collects the transaction fees.
-
Guess I'm still new at this and trying to figure stuff out but if only the miner who mines teh block collects fees what is the incentive for everyone to execute the smart contracst on their node if they're not even getting paid?– DaveCommented Feb 26, 2018 at 19:54
-
They do this to make sure the block that was mined is valid. If they don't do this, then they run the risk of working on an invalid blockchain. (Executing the code is a fairly trivial amount of computation.) Commented Feb 26, 2018 at 20:03
All the miners execute the contracts and all the transactions also, creating a new block with a deterministic new state for the blockchain with a small difference: every miner set his own address as the receiving address of the fees and the block reward.