-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNonStandardERC20Token.sol
52 lines (44 loc) · 1.31 KB
/
NonStandardERC20Token.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
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;
/**
* @title Token - a simple example (non - ERC-20 compliant) token contract.
*/
contract NonStandardERC20Token {
address private owner;
string public constant name = "NonStandardERC20Token";
uint256 private totalSupply;
mapping(address => uint256) private balances;
/**
* @param _totalSupply total supply to ever exist.
*/
constructor(uint256 _totalSupply) {
owner = msg.sender;
totalSupply = _totalSupply;
balances[owner] += totalSupply;
}
/**
* @param _amount amount to transfer. Needs to be less than balances of the msg.sender.
* @param _to address receiver.
*/
function transfer(uint256 _amount, address _to) external {
require(balances[msg.sender] >= _amount, "Not enough funds");
balances[msg.sender] -= _amount;
balances[_to] += _amount;
}
/**
* @param _address address to view the balance.
*/
function balanceOf(address _address)
external
view
returns (uint256 result)
{
result = balances[_address];
}
/**
* @notice returns the total supply.
*/
function getTotalSupply() external view returns (uint256 _totalSupply) {
_totalSupply = totalSupply;
}
}