1

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?

0

1 Answer 1

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.