-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathescrow.0.solb.exp
43 lines (35 loc) · 1.06 KB
/
escrow.0.solb.exp
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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
contract Escrow {
address payable payer;
address payable payee;
address payable arbiter;
uint amount;
uint 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 transfer(address _to, uint _amount) internal {
(bool _success, ) = _to.call{value:_amount}("");
require(_success, "transfer failed on receiver side");
}
function permit(address _authorized) internal view {
require(msg.sender == _authorized, "not permitted");
}
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);
}
}