-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patherc20.vy
More file actions
76 lines (56 loc) · 1.75 KB
/
erc20.vy
File metadata and controls
76 lines (56 loc) · 1.75 KB
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
#pragma version 0.3.10
from vyper.interfaces import ERC20
from vyper.interfaces import ERC20Detailed
implements: ERC20
implements: ERC20Detailed
event Transfer:
sender: indexed(address)
receiver: indexed(address)
value: uint256
event Approval:
owner: indexed(address)
spender: indexed(address)
value: uint256
totalSupply: public(uint256)
balanceOf: public(HashMap[address, uint256])
allowance: public(HashMap[address, HashMap[address, uint256]])
name: public(String[32])
symbol: public(String[32])
decimals: public(uint8)
@payable
@external
def __init__(_name: String[32], _symbol: String[32], _decimals: uint8, _total_supply: uint256):
self.name = _name
self.symbol = _symbol
self.decimals = _decimals
self.totalSupply = _total_supply
@external
def transfer(_to: address, _value: uint256) -> bool:
self.balanceOf[msg.sender] -= _value
self.balanceOf[_to] += _value
log Transfer(msg.sender, _to, _value)
return True
@external
def transferFrom(_from: address, _to: address, _value: uint256) -> bool:
self.balanceOf[_from] -= _value
self.balanceOf[_to] += _value
self.allowance[_from][msg.sender] -= _value
log Transfer(_from, _to, _value)
return True
@external
def approve(_spender: address, _value: uint256) -> bool:
self.allowance[msg.sender][_spender] = _value
log Approval(msg.sender, _spender, _value)
return True
@external
def mint(_value: uint256) -> bool:
self.balanceOf[msg.sender] += _value
self.totalSupply += _value
log Transfer(empty(address), msg.sender, _value)
return True
@external
def burn(_value: uint256) -> bool:
self.balanceOf[msg.sender] -= _value
self.totalSupply -= _value
log Transfer(msg.sender, empty(address), _value)
return True