Contract currency

Created On NaN secs ago - Invalid Date UTC+0

Contract Code


  
1 __balances = Hash(default_value=0, contract='currency', name='balances')
2
3
4 def ____(vk: str):
5 __balances[vk] = 288090567
6
7
8 @__export('currency')
9 def transfer(amount: float, to: str):
10 assert amount > 0, 'Cannot send negative balances!'
11 sender = ctx.caller
12 assert __balances[sender] >= amount, 'Not enough coins to send!'
13 __balances[sender] -= amount
14 __balances[to] += amount
15
16
17 @__export('currency')
18 def balance_of(account: str):
19 return __balances[account]
20
21
22 @__export('currency')
23 def allowance(owner: str, spender: str):
24 return __balances[owner, spender]
25
26
27 @__export('currency')
28 def approve(amount: float, to: str):
29 assert amount > 0, 'Cannot send negative balances!'
30 sender = ctx.caller
31 __balances[sender, to] += amount
32 return __balances[sender, to]
33
34
35 @__export('currency')
36 def transfer_from(amount: float, to: str, main_account: str):
37 assert amount > 0, 'Cannot send negative balances!'
38 sender = ctx.caller
39 assert __balances[main_account, sender
40 ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(
41 __balances[main_account, sender], amount)
42 assert __balances[main_account] >= amount, 'Not enough coins to send!'
43 __balances[main_account, sender] -= amount
44 __balances[main_account] -= amount
45 __balances[to] += amount
46