With a stunning design, connected to the blockchain, metamask pairing, interaction with smart contracts, sending Ethereum through the blockchain network, and writing solidity code.
i just want to ask why i always got an error that "the deadline must be a date in the future" when i the code below, tbh i try to edit a little bit of the code
`
function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Campaign storage campaign = campaigns[numberOfCampaigns];
require(_deadline < block.timestamp, "The deadline must be a date in the future");
// Fill campaign
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;
}
`
then after a while i compare the code and found that in the requre statement i use _deadline instead of campaign.deadline so i fix my code and the error dissapear.
my question is why this is happen, i have a little knowledge about programming but i still don't understand why this error is happening.
hey adrian thank you, this is a great tutorial.
i just want to ask why i always got an error that "the deadline must be a date in the future" when i the code below, tbh i try to edit a little bit of the code ` function createCampaign(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) { Campaign storage campaign = campaigns[numberOfCampaigns];
} `
then after a while i compare the code and found that in the requre statement i use
_deadline
instead ofcampaign.deadline
so i fix my code and the error dissapear.my question is why this is happen, i have a little knowledge about programming but i still don't understand why this error is happening.
Thank You in advance