I've found this item on the Subtleties page https://github.com/ethereum/wiki/wiki/Subtleties:

If contract initialization returns an empty array, then no contract will be created. This allows you to "abuse" contract initialization as an atomic multi-operation, which might be useful in some protocols where you want to do multiple things but you don't want some of them to be able to process without others.

Can anyone explain what it means? In particular the 2nd sentence.

1 Answer 1


Ths article Diving Into The Ethereum VM Part 5 — The Smart Contract Creation Process explains in detail the process of creating a contract.

In simpler terms:

  1. An empty contract is created with the contract address
  2. The constructor is executed as it were the contract to initialize it
  3. The constructor returns the contract code
  4. The returned code is stored as the contract code for future calls

The contract's constructor can execute any operation that is allowed inside the EVM, like calling another contract, make ether transfers, etc.

The "abuse" which refers the wiki page is that you can make two or more calls to externals contracts from the constructor. The transaction will succeed if all external calls succeed, so you are making sure that if any of the calls fails then all calls will be reversed. That is the atomicity the article mentions.

  • Is contract initialization "abuse" the only way to make atomic multi-operations? Nov 11, 2017 at 19:28
  • @medvedev1088 Currently only a contract can make multiple calls as a single operation.
    – Ismael
    Nov 11, 2017 at 20:55
  • Yes I meant instead of abusing the contract initialization one could just deploy a generic BatchContract that has a single method that allows you to execute atomic multi-operations. Is my understanding correct? Nov 11, 2017 at 21:39
  • @medvedev1088 You are correct, it should be possible to write such contract.
    – Ismael
    Nov 12, 2017 at 11:09

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .