I have a self escrow contract deployed on the Rinkeby Test Network. The goal of this contract is to store the owner's money for a period of time, and then pay it back when that period is over. Here is the code:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/
contract Storage {
int public start_date;
address payable public owner;
uint public amount_stored;
int public timeOut;
event Escrow(address owner, int time_out, uint amount_stored);
constructor() payable {
owner = payable(msg.sender);
}
function enter(int timeOutArg) public payable {
require(msg.value > 0.001 ether, "not enough eth");
require(timeOutArg < 10000 && timeOutArg > 0, "time out is not valid");
require(msg.sender == owner, "you are not the owner");
amount_stored = msg.value;
start_date = int(block.timestamp);
timeOut = timeOutArg;
emit Escrow(owner, timeOutArg, msg.value);
}
function getTimeLeft() public view returns (int) {
return start_date - int(block.timestamp) + timeOut;
}
function payMoneyOut() public {
require(msg.sender == owner, "you are not the owner");
require(getTimeLeft() < 5 || getTimeLeft() > 10000, "escrow is not done yet");
owner.transfer(amount_stored);
}
}
When I call the enter function it works fine, but when I call payMoneyOut it prompts me to pay for gas for the contract, but the contract never sends me the money that I paid in with enter. This is the link to the contract on Ethscan. I'm developing with the Mixer IDE.