-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathescrow.21.solx.exp
123 lines (91 loc) · 3.46 KB
/
escrow.21.solx.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
/* Lexon-generated Solidity code
code: Escrow
file: lexon/escrow.21.lex
compiler: lexon 0.3 alpha 93 U
grammar: 0.2.20 / subset 0.3.8 alpha 79 - English / Reyes
backend: solidity 0.3.93 U
target: solidity 0.8+
parameters: --solidity --all-auxiliaries
INSTRUCTIONS FOR USE:
Deploy this smart contract to the Ethereum blockchain or Goerli testchain. Replace
the <parameters> with literal values to interact with the contract via terminal.
Note that the instructions below reflect your lexon code, as well as the parameters
used during compilation of the code: different functions and parameters will result
from different input. Some functions are 'built-in' but only appear when needed as
per compiler options used during compilation – a list of which, is available with
lexon -h. The functions are given in the order of appearance, in the lexon source.
The required caller is noted in double angle brackets << >>. Some functions can be
called by anyone. Note that roles are being defined by using an address for it for
the first time. This will require for the same address to be used for the same role
after this point. Else, the call will revert.
Some clauses of the original lexon source text do not appear in the comments below.
Namely, those without permission phrase, wherefore they are regarded as internal.
These are the constructor parameters for deployment:
<payee : address payable>, <agent : address payable>, <fee : uint>
These are the state progress functions that allow to interact with the contract:
• <<Agent>> ⟶ pay_out()
• <<Agent>> ⟶ pay_back()
*/
/**
**
** Main Escrow contract system
**
**/
/** LEX Escrow.
*
* "Buyer" is a person.
* "Payee" is a person.
* "Agent" is a person.
* "Amount" is an amount.
* "Fee" is an amount.
*
* The Buyer pays an Amount into escrow, appoints the Payee, appoints the Agent, and fixes the Fee.
**/
contract Escrow {
address payable buyer;
address payable payee;
address payable agent;
uint amount;
uint fee;
bool amount__set = false;
constructor(address payable _payee, address payable _agent, uint _fee) payable {
buyer = payable(msg.sender);
amount = msg.value;
amount__set = true;
payee = _payee;
agent = _agent;
fee = _fee;
}
/* safe transfer */
function transfer(address _to, uint _amount) internal {
(bool _success, ) = _to.call{value:_amount}("");
require(_success, "transfer failed on receiver side");
}
/* built-in caller assertion */
function permit(address _authorized) internal view {
require(msg.sender == _authorized, "not permitted");
}
/* Pay Out clause */
/*
* CLAUSE: Pay Out.
* The Agent may pay from escrow the Fee to themselves, and afterwards pay the remainder of the escrow to the Payee.
*/
function pay_out() public {
permit(agent);
transfer(agent, fee);
transfer(payee, address(this).balance);
}
/* Pay Back clause */
/*
* CLAUSE: Pay Back.
* The Agent may pay from escrow the Fee to themselves, and afterwards return the remainder of the escrow to the Buyer.
*/
function pay_back() public {
permit(agent);
transfer(agent, fee);
transfer(buyer, address(this).balance);
}
}
/* end */