project_crowdfunding icon indicating copy to clipboard operation
project_crowdfunding copied to clipboard

-19411 days left ; No matter what I put in "End date" the end result is is this, all the campaigns showing "-19411 days left"

Open rohitx01 opened this issue 1 year ago • 2 comments

HELP!!!!! The End date in the form isn't working correctly!

rohitx01 avatar Mar 24 '23 15:03 rohitx01

Screenshot (256)

        Campaign storage campaign = campaigns[numberOfCampaigns];

        require(campaign.deadline < block.timestamp, "The deadline should be a date in the future.");

        campaign.owner = _owner;
        campaign.title = _title;
        campaign.description = _description;
        campaign.target = _target;
        campaign.deadline = _deadline;
        campaign.amountCollected = 0;
        campaign.image = _image;

        numberOfCampaigns++;

        return numberOfCampaigns - 1;
    }

I thought there was an error in this Solidity function, i.e. there should be a ">" symbol in require statement and redeployed after changing it , but the form couldn't be submitted anymore.

Does anyone know , How can I fix it?

rohitx01 avatar Mar 24 '23 15:03 rohitx01

@rohitx01 Are you still facing the error ?

I'd suggest to change the contract code require to following

require(_deadline > block.timestamp, "Deadline should be future date.");

Also, on getCampaigns are you converting the deadline to number before passing to contract call?

deadline: campaign.deadline.toNumber(),

A-Pradeep avatar Apr 08 '23 11:04 A-Pradeep