forked from crytic/properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestERC20Token.sol
74 lines (59 loc) · 1.96 KB
/
TestERC20Token.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;
import {IERC20} from "../../util/IERC20.sol";
contract TestERC20Token is IERC20 {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
constructor(string memory _name, string memory _symbol, uint8 _decimals) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
function approve(address spender, uint256 amount) public returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public returns (bool) {
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public returns (bool) {
uint256 spenderAllowance = allowance[from][msg.sender];
if (spenderAllowance != type(uint256).max) {
allowance[from][msg.sender] = spenderAllowance - amount;
}
balanceOf[from] -= amount;
balanceOf[to] += amount;
emit Transfer(from, to, amount);
return true;
}
function mint(address to, uint256 amount) public {
totalSupply += amount;
balanceOf[to] += amount;
emit Transfer(address(0), to, amount);
}
function burn(address from, uint256 amount) public {
totalSupply -= amount;
balanceOf[from] -= amount;
emit Transfer(from, address(0), amount);
}
function forceApproval(
address account,
address spender,
uint256 amount
) public {
allowance[account][spender] = amount;
emit Approval(account, spender, amount);
}
}