0
uint256 public max_contribution = 50 ether; 
    uint256 public min_contribution = 1 ether;

I added this to my ICO smart-contract, but still can do less than 1 ether transactions. What should i change there or may be how can i set minimal contribution in other way?

  • you can set these fields, but you need to use it in your code (transfer function) – mirg Apr 24 '18 at 9:37
  • function transfer(address to, uint tokens) public returns (bool success); uint256 public max_contribution = 50 ether; uint256 public min_contribution = 1 ether; like this? – Daniel Apr 24 '18 at 10:09
0
require(msg.value >= min_contribution);
require(msg.value <= max_contribution);

This checks wether the value that was send fits your specified restrictions. If it doesn't the transaction gets reverted.
So, you need to put this at the top of your transfer function. Work with a modifier if you are checking this in multiple functions.

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.