-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token.sol
34 lines (28 loc) · 872 Bytes
/
Token.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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
contract MyToken {
// public variables here
string constant public name = "Test token";
string constant public token = "TST";
uint constant public initial_supply = 1000000;
uint public total_supply = initial_supply;
// mapping variable here
mapping(address => uint) private balances;
// mint function
function mint(uint amount) external {
if(total_supply >= amount) {
total_supply -= amount;
balances[msg.sender] += amount;
}
}
// burn function
function burn(uint amount) external {
if(balances[msg.sender] >= amount) {
balances[msg.sender] -= amount;
total_supply += amount;
}
}
function balance() external view returns(uint) {
return balances[msg.sender];
}
}