-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTR.sol
73 lines (60 loc) · 3.03 KB
/
OTR.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface BEP20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
function getOwner() external view returns (address);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address _owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract MyToken is BEP20 {
string public override name = "OnTopOFTheRest"; // Numele token-ului
string public override symbol = "OTR"; // Simbolul token-ului
uint8 public override decimals = 9; // Numărul de zecimale
uint256 public override totalSupply = 10000000 * (10 ** uint256(decimals)); // Supply total
address public owner;
mapping(address => uint256) private balances;
mapping(address => mapping(address => uint256)) private allowances;
constructor() {
owner = msg.sender; // Proprietarul contractului
balances[owner] = totalSupply; // Alocarea inițială către proprietar
emit Transfer(address(0), owner, totalSupply);
}
function getOwner() public view override returns (address) {
return owner;
}
function balanceOf(address account) public view override returns (uint256) {
return balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
balances[recipient] += amount;
emit Transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address _owner, address spender) public view override returns (uint256) {
return allowances[_owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
require(balances[sender] >= amount, "Insufficient balance");
require(allowances[sender][msg.sender] >= amount, "Allowance exceeded");
balances[sender] -= amount;
balances[recipient] += amount;
allowances[sender][msg.sender] -= amount;
emit Transfer(sender, recipient, amount);
return true;
}
}