adrianhajdin / project_crowdfunding

With a stunning design, connected to the blockchain, metamask pairing, interaction with smart contracts, sending Ethereum through the blockchain network, and writing solidity code.
https://jsmastery.pro
704 stars 380 forks source link

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

Open rohitx01 opened 1 year ago

rohitx01 commented 1 year ago

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

rohitx01 commented 1 year ago

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?
A-Pradeep commented 1 year ago

@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(),