0

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.

1 Answer 1

0

If you look at the transaction log, under the "To" field, you can see the Ether was actually being sent back to you: TRANSFER 0.01 Ether From 0xab847dd1939ebdafacce7748175a87beb8e95961 To 0xd455b4c1485a3fe2af431dfa9451100b30bcbef6

2
  • 1
    Oh, I did not catch that, thanks! How come my balance is not updated in my metamask wallet?
    – Jakobi
    Jul 25, 2022 at 16:01
  • Welcome :) Hmm, I don't know. Maybe you're on the wrong account or network? I would probably try switching these back and forth. Jul 26, 2022 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.