Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created February 28, 2022 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominicFinn/eb10dc7d674bc45bc5796e8cf72d4b21 to your computer and use it in GitHub Desktop.
Save DominicFinn/eb10dc7d674bc45bc5796e8cf72d4b21 to your computer and use it in GitHub Desktop.
Escrow contract
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