1

This question already has an answer here:

To my understanding, the execution of the code inside a smart contract is done by all nodes in the network. However the miners are the only ones who receive the paid gas. Also, when setting up the mining client, the miner (person) can specify the gas price (or cost?) range to accept the job of executing a smart contract.

I am confused. If the smart contract is to be executed on every node of the network, why some miners can refuse to accept the job, and why is it fair that only the miners are rewarded, given that everyone is involved in the computation?

marked as duplicate by Ismael, Richard Horrocks, Roman Frolov, Dawny33, Jesse Busman Jan 20 '18 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Processing transactions and mining using Proof of Work are separate computations.

All nodes process all transactions to ensure other nodes aren't lying about what the state looks like after they're processed. Miners process all transactions and do Proof of Work which costs them money on energy and mining equipment.

The reward from Proof of Work is necessary to incentivise people to run nodes that take part in the mining process. The mining process randomly selects and rewards one node roughly every 15 seconds to update the network. If mining was removed, eg everyone was rewarded just for processing the transactions, then anyone could update the network at anytime and it would be trivial to double spend funds, rendering the network useless.

Regarding your first question, there's no way to force a miner to include a transaction but we encourage them to include a transaction with a transaction fee, which goes to the miner that includes that transaction in a block they create.

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