-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemecoin.sol
More file actions
42 lines (30 loc) · 1004 Bytes
/
Memecoin.sol
File metadata and controls
42 lines (30 loc) · 1004 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
34
35
36
37
38
39
40
41
42
pragma solidity ^0.8.4;
contract MemeCoin {
// public makes variables- accessible
address public minter;
mapping (address => uint) public balances;
uint public totalSupply;
// events allow clients to react to spec changes you declare
event Sent(address from, address to, uint amount);
//constructor code run
constructor() {
minter = msg.sender;
}
//sends amount of new created coins to addres and can only be called by creator
function mint(address reciever, uint amount) public {
require(msg.sender == minter);
balances[reciever] +=amount;
}
// errors allow you info about why failed
error InsufficientBalance(uint requesteed, uint available);
function send(address reciever, uint amount) public {
if(amount > balances[msg.sender])
revert InsufficientBalance({
requested: amount,
available: balances[msg.sender]
});
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent()
}
}