-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin.html
More file actions
138 lines (125 loc) · 5.12 KB
/
admin.html
File metadata and controls
138 lines (125 loc) · 5.12 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nawah Token Admin Interface</title>
<script src="https://cdn.jsdelivr.net/npm/web3@1.8.2/dist/web3.min.js"></script>
<style>
body {
font-family: Arial;
padding: 20px;
background: #f0f0f0;
direction: rtl;
}
h2, h3 {
color: #333;
}
button {
margin-top: 10px;
padding: 10px;
width: 100%;
background-color: #ffd700;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
}
input {
padding: 8px;
margin-top: 5px;
width: 100%;
border-radius: 5px;
border: 1px solid #ccc;
}
.section {
background: white;
padding: 20px;
margin-bottom: 20px;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0,0,0,0.1);
max-width: 600px;
margin-right: auto;
margin-left: auto;
}
</style>
</head>
<body>
<h2 style="text-align:center;">واجهة إدارة نواة توكن (Nawah Token)</h2>
<div class="section">
<p><strong>المحفظة المتصلة:</strong> <span id="account">-</span></p>
<p><strong>الرصيد:</strong> <span id="balance">-</span> NAWAH</p>
</div>
<div class="section">
<h3>🔥 حرق التوكن</h3>
<input id="burnAmount" type="number" placeholder="الكمية المراد حرقها" />
<button onclick="burnTokens()">تنفيذ الحرق</button>
</div>
<div class="section">
<h3>⛔ إيقاف / تفعيل العقد</h3>
<button onclick="pauseContract()">إيقاف العقد مؤقتًا</button>
<button onclick="unpauseContract()">تشغيل العقد</button>
</div>
<div class="section">
<h3>🔁 إرسال التوكن</h3>
<input id="transferTo" type="text" placeholder="عنوان المستلم" />
<input id="transferAmount" type="number" placeholder="كمية التوكن" />
<button onclick="transferTokens()">إرسال</button>
</div>
<script>
const contractAddress = "0x000000000000000000000000000000000000dEaD"; // ← استبدله لاحقًا بالعقد الرسمي
const contractABI = [
{ "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "burn", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "transfer", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
{ "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }
];
let account;
let nawToken;
async function connect() {
if (window.ethereum) {
window.web3 = new Web3(ethereum);
await ethereum.request({ method: 'eth_requestAccounts' });
const accounts = await web3.eth.getAccounts();
account = accounts[0];
document.getElementById("account").innerText = account;
nawToken = new web3.eth.Contract(contractABI, contractAddress);
updateBalance();
} else {
alert("يرجى تثبيت MetaMask.");
}
}
async function updateBalance() {
const balance = await nawToken.methods.balanceOf(account).call();
const decimals = await nawToken.methods.decimals().call();
const formatted = balance / 10 ** decimals;
document.getElementById("balance").innerText = formatted.toLocaleString();
}
async function burnTokens() {
const amount = document.getElementById("burnAmount").value;
const decimals = await nawToken.methods.decimals().call();
const raw = web3.utils.toBN(amount * 10 ** decimals);
await nawToken.methods.burn(raw).send({ from: account });
updateBalance();
}
async function pauseContract() {
await nawToken.methods.pause().send({ from: account });
alert("تم إيقاف العقد مؤقتًا.");
}
async function unpauseContract() {
await nawToken.methods.unpause().send({ from: account });
alert("تم إعادة تشغيل العقد.");
}
async function transferTokens() {
const to = document.getElementById("transferTo").value;
const amount = document.getElementById("transferAmount").value;
const decimals = await nawToken.methods.decimals().call();
const raw = web3.utils.toBN(amount * 10 ** decimals);
await nawToken.methods.transfer(to, raw).send({ from: account });
updateBalance();
}
window.onload = connect;
</script>
</body>
</html>