This is for a school project.
The purpose of the contract is to allow an Externally Owned Account to deposit some ether at any time, but there is a minimum time limit before they can withdraw.
I have no problem compiling and deploying, but when I try to call the deposit function, I receive an error.
I have no experience with debugging on Remix, so any help is much appreciated.
Here's the code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.10;
contract Savings {
address owner;
uint256 deadline;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function deposit(uint256 amount) public payable {
require(msg.value == amount);
}
constructor(uint numberOfDays) public payable {
owner = msg.sender;
deadline = block.timestamp + (numberOfDays * 1 days);
}
function withdraw() public onlyOwner {
require(block.timestamp >= deadline);
msg.sender.transfer(address(this).balance);
}
}
Thanks a lot!