-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathescrow.212.solx.exp
129 lines (100 loc) · 3.54 KB
/
escrow.212.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
124
125
126
127
128
129
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
/** Lexon-generated Solidity code
**
** code: Escrow
**
** file: lexon/escrow.212.lex
**
** compiler: lexon 0.3 alpha 97 U
**
** grammar: 0.2.20 / subset 0.3.8.2 alpha 97 - English / Reyes
**
** backend: solidity 0.3.97g U
**
** target: solidity 0.8.17+
**
** options: --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>, <arbiter : address payable>, <fee : uint>
These are the state progress functions that allow to interact with the contract:
• <<Arbiter>> ⟶ pay_out()
• <<Arbiter>> ⟶ pay_back()
*/
/**
**
** Main Escrow contract system
**
**/
/*
| LEX Escrow.
|
| "Payer" is person.
| "Payee" is person.
| "Arbiter" is person.
| "Amount" is amount.
| "Fee" is amount.
|
| The Payer pays Amount into escrow, appoints the Payee, appoints the Arbiter, and fixes the Fee.
*/
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;
}
/* built-in 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 Arbiter may pay from escrow the Fee to themselves, and afterwards pay the remainder of the escrow to the Payee.
*/
function pay_out() public {
permit(arbiter);
transfer(arbiter, fee);
transfer(payee, address(this).balance);
}
/* Pay Back clause */
/*
| CLAUSE: Pay Back.
| The Arbiter may pay from escrow the Fee to themselves, and afterwards return the remainder of the escrow to the Payer.
*/
function pay_back() public {
permit(arbiter);
transfer(arbiter, fee);
transfer(payer, address(this).balance);
}
}
/* end */