0

Time issue in Solidity ICO contract. Should I set time in future, 17.05.2018.10.00? and not use 'now' as I read it will not work. Warning below. use of "now": "now" does not mean current time. Now is an alias for block.timestamp.

Do I need to change gas, how much for a ICO contract? Warning below. Fallback function of contract nameToken requires too much gas (infinite). If the fallback function requires more than 2300 gas, the contract cannot receive Ether. Warning how to make changes so the ICO contract will work.

Gas requirement of function nameToken.approveAndCall(address,uint256,bytes) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)

Does this mean my token take can not be the same as contract name? why not?! nameToken.balanceOf(address) : Variables have very similar names balances and balance. Note: Modifiers are currently not considered by this static analysis.

Warning, ok just lost with this one,,,,,,,, Use assert(x) if you never ever want x to be false, not in any circumstance (apart from a bug in your code). Use require(x) if x can be false, due to e.g. invalid input or a failing external component.

2
  • Hi I have accepted this answer please so asking me to keep doing this. if there is a problem try Stack Exchange. Best wishes
    – ABonney
    Jul 25, 2018 at 8:25
  • acceptance noted, will upvote the question
    – ETHER
    Jul 25, 2018 at 15:10

2 Answers 2

1

time issue in Solidity ICO contract. Should I set time in future, 17.05.2018.10.00? and not use 'now' as I read it will not work. Warning below. use of "now": "now" does not mean current time. Now is an alias for block.timestamp.

Now give you the time stamp of the last block, so this will change with time.

Do I need to change gas, how much for a ICO contract? Warning below. Fallback function of contract nameToken requires too much gas (infinite). If the fallback function requires more than 2300 gas, the contract cannot receive Ether. Warning how to make changes so the ICO contract will work.

Increasing the gas will not solve any potential if the code that you have in the fallback uses more than 2300, the transaction will fail. You can also create another payable function with an argument and that one will take more than 2300, solving your problem.

Gas requirement of function nameToken.approveAndCall(address,uint256,bytes) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)

impossible to know without taking a look at your code, but most of these warnings are due to the use of strings or dynamic arrays. This doesn't mean that it won't work but is necessary to be sure that this will not create potential issues.

Does this mean my token take can not be the same as contract name? why not?! nameToken.balanceOf(address) : Variables have very similar names balances and balance. Note: Modifiers are currently not considered by this static analysis.

This just means what it says, the variables have similar names and you may get confused and make mistakes.

Warning, ok just lost with this one,,,,,,,, Use assert(x) if you never ever want x to be false, not in any circumstance (apart from a bug in your code). Use require(x) if x can be false, due to e.g. invalid input or a failing external component. more

So probably you are using require() this warning is just a reminder that require() and assert() are used for different things. The compiler is not smart enough to tell you when one or the other can be used so it just warns you about the correct usage.

2
  • I guess Anne is name of OP. :p May 14, 2018 at 9:52
  • thank you I will try it out, Anne Bonny was a pirate in the 1700 's
    – ABonney
    May 14, 2018 at 14:30
1

Should I set time in future, 17.05.2018.10.00? and not use 'now' as I read it will not work. Warning below. use of "now": "now" does not mean current time. Now is an alias for block.timestamp.

now or block.timestamp is reliable or not depends on the timeframe you are talking about. now does not means the time of sending the tx but the time block being added to blockchain (hence called block.timestamp). So if you provide sufficient gas and gas price the transaction is mined and added to block within 2 mins (this is an approximation). So the time difference you can suffer is 2 mins depending on when your transaction is added to blockchain.

In case of ICOs, 5-10 mins hardly matter, so you can rely on the timestamp. Or you can use epoch time directly if you want to be more accurate. I prefer the later one.

Do I need to change gas, how much for a ICO contract? Warning below. Fallback function of contract nameToken requires too much gas (infinite). If the fallback function requires more than 2300 gas, the contract cannot receive Ether. Warning how to make changes so the ICO contract will work.

Generally, it's not recommended to keep complex logic in fallback function because the default stipend in 23000 gas which is not sufficient for executing complex logics. But again this is not an issue if you specify the gas manually. The most wallet like MEW, Metamaks does that for you.

Gas requirement of function nameToken.approveAndCall(address,uint256,bytes) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)

I guess you are compiling the code on remix compiler. This happens with remix, when it is not able to estimate gas it throws such warnings. Better you deploy your contract on test-net or private net. If it works perfectly there, it most likely to work on main-net as well.

Rest all are just warnings and can be neglected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.