-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathERC20basic.sol
More file actions
33 lines (27 loc) · 901 Bytes
/
ERC20basic.sol
File metadata and controls
33 lines (27 loc) · 901 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
contract Token {
uint public totalSupply = 0;
string public name = "MGCOIN";
string public symbol = "uwu";
uint8 public decimals = 18;
event Transfer(address, address, uint256);
mapping(address => uint256) balance;
constructor () {
totalSupply = 1000 * (10 ** 18);
balance[address(msg.sender)] = totalSupply;
}
function balanceOf(address person) external view returns (uint256) {
return balance[person];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
uint256 userAmt = this.balanceOf(msg.sender);
if (userAmt < amount) {
revert("not enough");
}
balance[recipient] += amount;
balance[msg.sender] -= amount;
emit Transfer(msg.sender, recipient, amount);
return true;
}
}