Created
February 28, 2022 21:52
-
-
Save DominicFinn/eb10dc7d674bc45bc5796e8cf72d4b21 to your computer and use it in GitHub Desktop.
Escrow contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.2; | |
contract Escrow { | |
// the person who will pay the funds | |
address public payer; | |
// the person who will recieve funds | |
address public payee; | |
// the lawyer / solicitor, controller of the funds | |
address public lawyer; | |
constructor(address _payer, address payable _payee, uint _amount) { | |
payer = _payer; | |
payee = _payee; | |
lawyer = msg.sender; | |
amount = _amount; | |
} | |
function deposit() payable public { | |
require(msg.sender == _payer, "sender must be the payer"); | |
require(address(this).balance <= amount); | |
} | |
function release() public { | |
require(address(this).balance == amount, "cannot release the funds until the Escrow is fully funded"); // the escrow must be 100% funded | |
require(msg.sender == lawyer, "only the lawyer / controller of the escrow contract can release the funds") | |
payee.transfer(amount); | |
} | |
function balanceOf() view public returns(uint) { | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment