On Ethereum, I understand that one can create a contract and deploy it onto the blockchain. But I am not clear how this contract gets verified by miners before being deployed onto the chain. For example, it can be a voting contract as shown here or some other contract for my purpose.

Also, is there any tutorial for programming a miner to verify a specific behaviour, like if there is any infinite loop in the contract deployed.


When deploying a contract miners will only execute its constructor. If the constructor finishes correctly the contract will be added to the Ethereum's world state.

There's no other verification Miners only execute a sequence of EVM opcodes, they make no verification if the sequence of opcodes was matches a source code.

Some block explorer provide "verified" sources that matches the deployed opcodes. But that is an extra service and you have to trust the reputation of the block explorer.

  • Thank you for your answer. Can you please provide a reference for this information? Any idea about how we can code miner program? – K Kolluru Mar 14 '18 at 9:30
  • 1
    The cannonical formal reference is Ethereum's Yellow Paper, but it is too technical. There's a nice article that deals with the Contract creation process. If you only want to implement a miner perhaps taking a look a the implementation of cpp-ethereum miners is a better place. – Ismael Mar 14 '18 at 17:05

When smart contract is deployed, its byte code is executed starting from the beginning. This actually executes the constructor of the smart contract, and at the end of execution constructor usually loads into memory byte code of the rest of smart contract, i.e. byte code of the smart contract with constructor code stripped form the beginning, and returns offset and length of the loaded byte code.

This constructor execution may be treated as "verification" of byte code because EVM will revert the transaction in case byte code will try to do something illegal, e.g. execute opcode that EVM does not know, or jump to an instruction other than JUMPDEST, etc. Though only constructor code is "verified" at this stage.

When deployed smart contract is called by a transaction, EVM executed its byte code, as it was returned by constructor, and this execution may also be treaded as "verification". Though, only the parts of byte code laying across execution path are "verified".

In other words, miner "verifies" only those parts of byte code that he executes, and only when he executes them. The whole smart contract is never verified. Moreover, there could be unreachable parts of byte code, and that part will never be verified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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