-
Notifications
You must be signed in to change notification settings - Fork 4
/
DummyERC20Impl.sol
57 lines (51 loc) · 1.6 KB
/
DummyERC20Impl.sol
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
// SPDX-License-Identifier: agpl-3.0
pragma solidity >= 0.8.0;
// with mint
contract DummyERC20Impl {
uint256 t;
mapping (address => uint256) b;
mapping (address => mapping (address => uint256)) a;
string public name;
string public symbol;
uint public decimals;
function myAddress() public returns (address) {
return address(this);
}
function add(uint a, uint b) internal pure returns (uint256) {
uint c = a +b;
require (c >= a);
return c;
}
function sub(uint a, uint b) internal pure returns (uint256) {
require (a>=b);
return a-b;
}
function totalSupply() external view returns (uint256) {
return t;
}
function balanceOf(address account) external view returns (uint256) {
return b[account];
}
function transfer(address recipient, uint256 amount) external returns (bool) {
b[msg.sender] = sub(b[msg.sender], amount);
b[recipient] = add(b[recipient], amount);
return true;
}
function allowance(address owner, address spender) external view returns (uint256) {
return a[owner][spender];
}
function approve(address spender, uint256 amount) external returns (bool) {
a[msg.sender][spender] = amount;
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool) {
b[sender] = sub(b[sender], amount);
b[recipient] = add(b[recipient], amount);
a[sender][msg.sender] = sub(a[sender][msg.sender], amount);
return true;
}
}