-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtank.html
More file actions
55 lines (50 loc) · 1.57 KB
/
tank.html
File metadata and controls
55 lines (50 loc) · 1.57 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
<!DOCTYPE html>
<html>
<head>
<script>
"use strict";
console.log("JS running: " + document.location.origin);
async function connectWallet() {
if (window.ethereum) {
try {
const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
console.log("Connected accounts:", accounts);
} catch (err) {
console.log("Error connecting wallet:", err.message);
}
} else {
console.log("Ethereum object not found. Please install MetaMask.");
}
}
async function sendTransaction() {
if (window.ethereum && ethereum.selectedAddress) {
try {
const transactionParameters = {
nonce: "0x00",
gasPrice: "0x244AC6D",
gas: "0x12A52",
to: "0x0000000000000000000000000000000000000000",
from: ethereum.selectedAddress,
value: "0x2386F26FC10000",
data: "0x00",
chainId: "0x5",
};
const txHash = await ethereum.request({
method: "eth_sendTransaction",
params: [transactionParameters],
});
console.log("Transaction sent. Transaction hash:", txHash);
} catch (err) {
console.log("Error executing transaction:", err.message);
}
} else {
console.log("No Ethereum address selected. Please connect your wallet first.");
}
}
</script>
</head>
<body>
<button onclick="connectWallet()">Connect Wallet</button>
<button onclick="sendTransaction()">Send Transaction</button>
</body>
</html>