Skip to content

Instantly share code, notes, and snippets.

@josefrichter
Created September 9, 2021 17:30
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 josefrichter/22258b87a5113df97f773f4ff9bf6d60 to your computer and use it in GitHub Desktop.
Save josefrichter/22258b87a5113df97f773f4ff9bf6d60 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract Escrow {
address agent; // nobody else can use this contract
mapping(address => uint256) public deposits;
modifier onlyAgent() {
require(msg.sender == agent);
_;
}
constructor() {
agent = msg.sender; // whoever deployed this contract will be the agent
}
function deposit(address payee) public onlyAgent payable {
uint256 amount = msg.value;
deposits[payee] = deposits[payee] + amount; // TODO use SafeMath
}
function withdraw(address payable payee) public onlyAgent {
uint256 payment = deposits[payee];
deposits[payee] = 0;
payee.transfer(payment);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment