-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathescrow.0.solb.exp
More file actions
46 lines (35 loc) · 1.12 KB
/
escrow.0.solb.exp
File metadata and controls
46 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
contract Escrow {
address payable public payer;
address payable public payee;
address payable public arbiter;
uint public amount;
uint public fee;
bool amount__set = false;
constructor(address payable _payee, address payable _arbiter, uint _fee) payable {
payer = payable(msg.sender);
amount = msg.value;
amount__set = true;
payee = _payee;
arbiter = _arbiter;
fee = _fee;
}
function permit(address payable _authorized) internal view {
require(msg.sender == _authorized, "not permitted");
}
function transfer(address payable _to, uint _amount) internal {
(bool _success, ) = _to.call{value:_amount}("");
require(_success, "transfer failed on receiver side");
}
function pay_out() public {
permit(arbiter);
transfer(arbiter, fee);
transfer(payee, address(this).balance);
}
function pay_back() public {
permit(arbiter);
transfer(arbiter, fee);
transfer(payer, address(this).balance);
}
}