-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleEscrow.vyp
50 lines (42 loc) · 1.01 KB
/
simpleEscrow.vyp
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
# Escrow Smart Contract
# Events
event Deposit(address indexed sender, uint value)
event Refund(address indexed sender, uint value)
event Release(address indexed sender, address indexed receiver, uint value)
# Variables
address public owner
address public escrow
address public seller
address public buyer
uint public amount
bool public locked
# Modifiers
modifier onlyOwner { require(msg.sender == owner); _; }
modifier onlyEscrow { require(msg.sender == escrow); _; }
# Constructor
def __init__():
owner = msg.sender
# Deposit
@onlyOwner
def setEscrow(address _escrow):
escrow = _escrow
@onlyEscrow
def deposit(address _seller, address _buyer, uint _amount):
require(!locked)
seller = _seller
buyer = _buyer
amount = _amount
locked = true
emit Deposit(seller, amount)
# Refund
@onlyEscrow
def refund():
require(locked)
locked = false
emit Refund(seller, amount)
# Release
@onlyEscrow
def release():
require(locked)
locked = false
emit Release(seller, buyer, amount)