I'm following this tutorial: link for building a private parity blockchain, for some reason I have to insert some binary data into smart contract. What do I have to do to let the smart contract store more than 1MB of data?

For Parity client I use web3j.

My code:

Contract contract = Contract.deploy(web3j, credentials, BigInteger.valueOf(5000L), BigInteger.valueOf(100_000_000L), bytes).send();

It always shows error: "Transaction is too big, see chain specification for the limit.".

I tried to increase "gasLimit" in chain spec but it seems not working.

Any help would be appreciated. Thanks.


Parity enforces a 300 kb limit on transaction size for the txpool, and geth enforces a lower, 32 kb limit.

You can set a custom max size for Parity in the chain specification. For geth nodes, you will have to edit the source and recompile.

Note that this is not a consensus rule, and if a block contains a larger tx, it is still valid. These limits only apply to the pending tx pool.

Do note that storage costs 20000 gas for a 256 bit word, so storing 1 MB of data would cost you around 640,000,000 gas, which is far greater than the block gas limit on every network (I hope). In general, if you need to store that much data on the chain, you may want to rethink your use.

  • Thanks alot after add maxTransactionSize, I can now upload 2MB of data. But I seems the limit become 2.5MB, But what I set in maxTransactionSize is 10MB. Everytime I deploy over 2.5MB, web3j shows the error: org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: okhttp3.internal.http.RealResponseBody Any chance you know why this happens? I know upload large data in blockchain is silly but this is just an experiment. Thanks in advance.
    – Hrabal Wei
    Aug 17 '18 at 8:40

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.