This question already has an answer here:

Let say I have a code that print "Hello World". I deploy it to the blockchain and pay 1000 gas for it. Will my code keep running for every subsequent block till it runs out of gas? Or will it only run when other user interact with it?

marked as duplicate by Ismael, eth Jul 5 '17 at 5:36

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.


Your code only runs when somebody sends it a transaction, using the gas sent with that transaction. A transaction is executed as part of a block.

PS. The resource the EVM controls is basically a shared database. It doesn't have a console, so you can't print "Hello World". But you could write "Hello World" to storage, or to the event log.

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