-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token.sol
43 lines (26 loc) · 840 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
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
contract Token{
address public minter;
mapping(address => uint)public balances;
event Sent(address from , address to,uint amount);
constructor(){
minter=msg.sender;
}
function mint(address reciver ,uint amount) public{
require(msg.sender==minter);
balances[reciver] +=amount;
}
error insufficientBalance (uint req,uint available);
function send(address reciver,uint amount)public{
if(amount > balances[msg.sender]){
revert insufficientBalance({
req:amount,
available:balances[msg.sender]
});
}
balances[msg.sender] -=amount;
balances[reciver]+=amount;
emit Sent(msg.sender,reciver,amount);
}
}