InsideDarkWeb.com

Truffle Deploy gas limit exhausted

I kept on getting this error. 9/10 of my deployment will fail. But out of the sudden it will be success without any reason.

I have checked the transaction receipt and indeed it had reaches the gas limit. The weird thing is, no matter how high I set, the limit will always be hit (until it reaches the block gas limit)

Saving successful migration to network...
  ... 0x4767ac8dbe6496fad283fd0185557f1fa56bd8772f9e6e727a385a31938d7179
  ... 0xeab261e0b015da89e96607cc20de26678a1d75c88fc1d5307ac526aad539d15d
Saving artifacts...
(node:7376) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: The contract code couldn't be stored, please check your gas amount.
(node:7376) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

truffle Configuration

development: {
  host: "localhost",
  port: 8545,
  from: "0xc8caa71c16299b40b8579742a27ee53162886040",
  gas: "900000000",
  gasPrice: "3000000000",
  network_id: "*" // Match any network id
},

The ciritcal part of the migration script:

deployer.deploy(V);
deployer.deploy(L).then(async () => {
  deployer.deploy(X, L.address);
});

The X is failing. It’s constructor is depending on the address of L. If your earlier guess is correct, then most likely this is the part that gives error.

Ethereum Asked on November 18, 2021

1 Answers

One Answer

It very likely is a valid contract is too large error. One thing you can try is to add the optimizer to your solidity compiler config, which will be located in your truffle.js config file. This will run a process on the assembly code during compilation, making it more efficient.

You can find a more detailed explanation here

compilers: {
    solc: {
        version: "^0.5.0",
        settings: {
            optimizer: {
                enabled: true,
                runs: 200
            }
        }
    }
}

Answered by shkfnly on November 18, 2021

Add your own answers!

Related Questions

History of Ethereum

1  Asked on February 22, 2021 by phil-boltt

 

Transferring an ERC-20 using web3js 1.0.0

1  Asked on February 21, 2021 by john-murphy

       

Nethereum C# FilterInput.GetAllChanges always empty

1  Asked on February 12, 2021 by exaltedoil

       

Testing Gas Token on testnet failing transaction

0  Asked on February 9, 2021 by marr

   

I am unable to install web3 on my mac

1  Asked on February 5, 2021 by saiteja-kuruva

 

Out of stack DUP2 1/1024 when adding string to parameter

0  Asked on February 1, 2021 by koukotsu

   

How to find contract’s address?

6  Asked on January 31, 2021 by user3280964

   

Import error in Truffle Pet Shop tutorial

1  Asked on January 29, 2021 by xpain

   

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.