I would like to understand which of the following patterns is better.

Say my use case is to have two types of users in my platform buyer and seller for a product, with regard to my architecture Im left with two options.

  1. To have one contract which would have a struct defination of types of Users(Buyer/Seller) and Product.
  2. To have dedicated contract for each module. - Have noticed this in git projects

I belive the product can be achived with both ways, However I would like to understand which approach is better in efficently coding using Blockchain.

  • 1
    This really comes down to style. Doing it in one contract is more efficient, and my personal choice, but contracts only cause a little bit of inefficiency and can make the code more readable, modular, and testable. Commented Dec 9, 2016 at 1:11
  • Thank's I get that, need one clarity is it true that having one contract would cost less over multiple contracts? cause more contract would require multiple operations. Commented Dec 9, 2016 at 8:54
  • Yes, having one contract will cost less than having multiple. I personally find it easier to reason about one contract, as well Commented Dec 9, 2016 at 15:00
  • 1
    Very similar to this question: ethereum.stackexchange.com/questions/8615/…
    – hurb
    Commented Jan 27, 2017 at 11:39

1 Answer 1


I think it comes down to more of your goals. One contract is easier/more efficient by far, especially for finding everything (and is cheaper), but at the same time it's more centralized. For instance if you are storing loads of Eth in the contract, have very complex code, and want lots of users to interact with it, a lot of value in one contract is not necessarily the best idea. Also from a control/regulatory standpoint, having multiple contracts with distributed ownership (i.e. users own their own contract) can be a benefit.

Like hurb said though, this person gave some good reasons: Child contract vs struct

  • This is a fair point, but note that if there's a bug that's replicated over different contracts then it makes no difference.
    – Symeof
    Commented Sep 20, 2018 at 13:45

Your Answer

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

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