I have two contracts A and B, both deploy and work correctly in ganache (they both use less than 6M gas). Now I want to create a third contract C that inherit both A and B.

contract C is A, B {

This contract C fails to deploy with out of gas exception. But gas should not be an issue because ganache is configured with a block gas limit of 4 billion.

After trial and error commenting out my code, I found it fails with a public function in contract B. After reordering functions I found it doesn't matter which function in particular, it will fail if there are more than N public functions in contract B.

Update: Trying the deploy the same contracts in a geth private testnet causes the error "oversized data". So I think is not the number of public functions but the resulting contract is too big.

  • So i take it your tried changing the last public function to internal or external ? Commented Apr 24, 2018 at 13:14
  • 1
    Yes, changing function to internal or private will make it work. I didn't try external.
    – Ismael
    Commented Apr 24, 2018 at 13:19
  • what is the exact error you are seeing, any chance its 'Stack too deep'? Commented Apr 25, 2018 at 0:09
  • @Legman As mentioned in the question the error out of gas when deploying the resulting contract.
    – Ismael
    Commented Apr 25, 2018 at 1:12

1 Answer 1


There is exactly one place in geth code where "oversized data" is thrown. It's in func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error.

Heuristic limit, reject transactions over 32KB to prevent DOS attacks

Moreover, there is also a limit for bytecode size of a smart contract. It's 24576 bytes (see protocol_params.go).

maxCodeSize can be set in genesis.json. 32KB for TX size limit is a hard-coded constant in the code.

  • I think you are right, it is not about public functions, it is just happen that public function generate more code and that little extra pushes the code beyond the accepted size.
    – Ismael
    Commented Apr 25, 2018 at 17:38
  • how to set maxCodeSize? is it under the config?
    – Nathan Aw
    Commented Aug 2, 2018 at 10:00
  • It‘s a constant in the code.
    – ivicaa
    Commented Aug 2, 2018 at 10:07

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.