I have a bunch of contracts which deploy just fine.

Deployment of one of the contracts, XBRNetwork takes exactly 5418911 gas - no problems with that.

However, once I add another trivial (public) function to the contract, deployment during CI run for the PR fails:

   Replacing 'XBRNetwork'

Error:  *** Deployment Failed ***

"XBRNetwork" ran out of gas (using a value you set in your network config or deployment parameters.)
   * Block limit:  0x989680
   * Gas sent:     10000000

    at /home/oberstet/scm/crossbario/xbr-protocol/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.11 (core: 5.1.11)
Node v10.16.0
Makefile:110: recipe for target 'deploy' failed
make: *** [deploy] Error 1

I have set:

What other option do I need? How would I change the PR to get rid of the "out of gas" issue?

Do test, start ganache:

docker-compose up --force-recreate ganache

and deploy

truffle migrate --reset --network ganache

UPDATE (solution)

The real reason (see the answer) is: apparently, there is a 24kB size restriction on the deployed bytecode (besides the gas limits).

I have added this helper to our CI:




(cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py 
ABI file "abi/XBRNetwork.json           " bytecode= 25547  bytes, deployedBytecode= 23998  bytes 


(cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py 
ABI file "abi/XBRNetwork.json           " bytecode= 26344  bytes, deployedBytecode= 24795  bytes   WARNING - maximum deployed contract size of 24kB exceeded

And the actual solution consequently: refactoring the contract code into a library. Can be done .. np .. now that I know this hidden limit;)

  • where are you deploying to? If it's your own private network it will have it's own maximum gas per block, which you could be exceeding?
    – Zakalwe
    Commented Feb 3, 2020 at 16:54
  • this might help: ethereum.stackexchange.com/questions/46957/…
    – Zakalwe
    Commented Feb 3, 2020 at 16:57
  • 1
    Check the size of the byte-code (bin file). If the byte-code is larger than 24KB (the bin file larger than 48KB) after you add that function, then it would explain it. Commented Feb 3, 2020 at 17:09

1 Answer 1


I took the liberty of checking the size of your contract's byte-code in your GitHub repository.

It turns out to be 51708 hexadecimal characters, which means ‭25854‬ bytes when deployed.

Ethereum has a contract code-size limit of 24KB, i.e., ‭24576‬ bytes.

If you contract's code-size exceeds this limit, then your contract deployment will fail.

  • yes, that was exactly the problem! I'll update the question with what I did exactly. anyways: thanks so much! =) I don't think I would have been able to find this actual reason: the "out of gas error" is .. misleading at best if you don't happen to know this 24kB bytecode size restrictions. I wasn't aware, and wasted like 10+ hours on this. well. thanks again!
    – oberstet
    Commented Feb 3, 2020 at 18:26
  • 1
    @oberstet: You're welcome. I think I must have spent 4-5 hours myself when I first encountered that problem. And you're right, the "out of gas error" is misleading. I'm actually quite sure that I've mentioned this fact when I answered here a question similar to yours a while ago. Commented Feb 3, 2020 at 19:59

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.