As a newbie, I am a bit confused...

I understand that a contract is a set of conditions the certain parties agreed upon, and that some actions may/should follow as a part of an agreement.

  1. What I do not understand is whether the miners always execute the contract when they encounter it, or whether there is some kind of a trigger that tells the miners whether to execute the contract or not?

  2. What if contracts become outdated and obsolete, and do not apply to a real-world anymore but can be executed regardless... wouldn't that be a waste of resources, and how is this situation handled ?

  3. What if contract executes to do something stupid such as sending the spam or access the certain website to initiate a DoS attack... It cannot be deleted, it is decentralized, miners have no clue, etc. How is this prevented ?

If there is some kind of a trigger that tells the miners whether to execute it:

  1. Could there be a sort of a null-trigger that tells the miners to always execute the contract ?

  2. What is the set of conditions that miners process before processing the contract, and where is this programmed (if inside of a contract, then it must be a separate section of a code that acts as an execution trigger only, otherwise a contradiction) ?

  3. Does the trigger need to be the money/ETH or can we use something else (for example, data from a weather station instead of ETH transactions) ?


2 Answers 2


It looks like I thought that Ethereum was a much bigger animal, or something completely different. Some of the questions I asked do not apply to Ethereum. The answer was well-written on Quora, and below is the copy-paste.

One way to understand Ethereum is to think of it as a special kind of bank containing all the money in the world. This means that there are no transactions to and from other banks. All transactions happen within. More importantly, it has no employees and instead operates by the consensus of its customers.

Like many other banks, Ethereum maintains bank accounts for its customers, each containing some money denominated in a currency called Ether. When one customer transfers money to another customer, the bank does not withdraw physical cash from one account and deposit it in the other. Instead, it simply increments the balance of the recipient account, and decrements the balance of the originating account.

In this way, you can see that the list of account balances is the “ground truth” - it is the ultimate arbiter of who is wealthy and who isn’t. In Ethereum, this list of accounts and their balances is known as the state. Every transaction can thus been seen as a state transition.

enter image description here

Executing a contract could involve several transactions. In our special Ethereum bank, it is not only people that have bank accounts - contracts have bank accounts too. In fact, one helpful way to think of contracts is to imagine them as people who execute instructions just as lawyers execute wills.

Executing a contract typically starts with the recipient, sender, third-party or even another contract, triggering the contract by making a transaction to it. You would think that it would be a cashless transaction since we are only triggering the movement of money. However, as with lawyers, you have to pay them for their services and they often charge by the hour. In Ethereum, the amount of work taken to execute the contract is denoted in a quantity called Gas. Different contracts may charge you different amounts of Ether for each unit of Gas. The triggering party has to foot this bill of say X amount. The contract, whose balance already contains the money to be paid out, will then make a transaction to pay the agreed upon amount, say Y, to the receiver. This completes the execution of the contract.

We can verify that the contract has been executed correctly by ensuring that the two state transitions occurred correctly. After the first transaction, the triggering account should have decreased by X Eth, and the contract’s account should have increased by the same amount. After the second, the contract’s account should have decreased by Y Eth and the recipient’s account should have increased by the same amount.

In our special bank, if most of its customers, even those not involved in the transaction, make these computations and agree on the end state, the outcome is ratified and taken as truth. The bank then moves on to processing the next transaction.


The Ethereum White paper contains more details. It is remarkably comprehensible for a technical document explaining novel concepts. White Paper · ethereum/wiki Wiki · GitHub


You wrote a pretty long post to your own question here, but I think it's important to clarify some misconceptions you have.

Fundamentally, miners are just processing transactions. They're not iterating through contracts on the blockchain, or doing any sort of automatic execution of contract code. This prevents a lot of the issues you've raised yourself, and it creates limitations that explains why you can't do a cron-type of scheduled execution of any function.

Even creating a contract is a transaction, as you can easily see in a fiddle: https://ethfiddle.com/F1ZHdfVEsc

enter image description here

Your Answer

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

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