0

When I deploy contract test net, it shows an error that gas limit exceeds: 3000000 What's the solution?

Github Link to the smart contract.

And is it normal to have the infinite gas estimate of almost all the functions?

enter image description here

0

I found this to be the case in most of my methods, especially the ones with a loop, for example when iterating over an array to look for an item to remove.

0

I do non know your application, but there I see a “decimal()” with infinite gas estimation. If it is something like the same function in ERC20 it is not justified.

May be you are dereferencing to other SC that are not known at the deploy time, or that you use dynamic arrays, strings included, or that you have for loops with indefinite maximum number of iterations. In those cases the estimation is not adequate and fails.

You should compare this results with those from the working application you run at development time on ganache or JavaScript VM local testnet. If the total amount of gas is something near to the limit on ropsten or whatever, do optimize your code and all shall be ok.

0

I tried to compile your contract with Solidity 0.4.18 with optimizations disabled, and deploy costs 3,224,320 gas for me. However, with optimizations it consts only 1,682,401 gas. So either enable optimizations or increase gas limit.

The warning about infinite gas look like static analyser bug. The following line is treated as consuming infinite gas:

balances[msg.sender] = balances[msg.sender].sub(_value);

But rewriting it like this solves the problem:

balances[msg.sender] = SafeMath.sub (balances[msg.sender], _value);

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.