codedamn

ICO contract

Created by Kshitij about a year ago

0

No description provided

5 Comments

    0

    quick question, in the invest() function it is defined to update the balances() before calling the transfer() function from the token's contract.... Does that code will update twice the balances?

    1. First time in the invest() function
    2. And when the transfer() function is executed, inside the transfer() function the balances are updated again.....

    Am I missing something?

    0

    I get this after deploying the ICO sir

    creation of ICO errored: Error encoding arguments: Error: invalid address (argument="address", value="", code=INVALID_ARGUMENT, version=address/5.5.0) (argument=null, value="", code=INVALID_ARGUMENT, version=abi/5.5.0)

    What can i do?

    @poise1234

    Poise-Paul

    @poise1234

    0

    Hello sir the icoEnd Variable is initialized as = block.timestamp+3 instead of +3600 // 1 hour = (60 * 60) seconds

    @poise1234

    Poise-Paul

    @poise1234

    6

    A small suggestion. The above code is perfectly suitable for beginners but if you wanna get serious about it, there's a bug in the code. The maximum one can invest is 10 ether but the user can keep on investing repeatedly as the invest() doesn't check the amount the msg.sender has already invested. So, for that, I have used something which might be helpful.

    I have created a new state variable: mapping(address => uint) public invested;

    and then, here is the updated invest() function:

    function invest() payable public returns (bool) { require(getState() == State.running); require(msg.value >= minInvest && msg.value <= maxInvest); invested[msg.sender] += msg.value; require(invested[msg.sender] >= minInvest && invested[msg.sender] <= maxInvest, "Limit exceeded."); raisedAmount += msg.value; require(raisedAmount <= marketCap); uint tokens = msg.value/tokenPrice; balance[msg.sender] += tokens; balance[founder] -= tokens; deposit.transfer(msg.value); emit Invest(msg.sender, msg.value, tokens); return true; }

    Suggestions to me are welcomed.

    @tarunvadde

    Tarun Vadde

    @tarunvadde

    0

    hey kshitij, good content and simple explanation, but why do we not have any exercises after practice labs section? Its just a lot of explanation without any practice so it becomes difficult to remember

    @maayyaannkk

    mayank nagwanshi

    @maayyaannkk

Your comment