-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW7day3.sol
More file actions
46 lines (33 loc) · 1.2 KB
/
W7day3.sol
File metadata and controls
46 lines (33 loc) · 1.2 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract RasheedToken{
string public name;
string public symbol;
uint256 public decimals;
uint256 private _totalSupply;
mapping(address => uint256) public balances;
constructor(string memory _name, string memory _symbol, uint256 _decimals, uint256 initialSupply){
name = _name;
symbol = _symbol;
decimals = _decimals;
balances[msg.sender] = initialSupply;
//_totalSupply = 5000000;
}
function totalSupply() public view returns(uint256){
return _totalSupply;
}
function balanceOf(address account) public view returns(uint256){
return balances[account];
}
event Transfer(address indexed from, address indexed to, uint256 value);
error InsufficientBalance();
error InvalidAddress();
function transfer(address to, uint256 amount) public returns (bool){
require(balances[msg.sender] >= amount, InsufficientBalance());
require(to != address(0), InvalidAddress());
balances[msg.sender] -= amount;
balances[to] += amount;
emit Transfer(msg.sender, to, amount);
return true;
}
}