-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
169 lines (156 loc) · 5.18 KB
/
index.html
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Token Rug Rate Analyzer</title>
<style>
/* Simple styling for a clean, attractive interface */
body {
font-family: Arial, sans-serif;
background: #f0f2f5;
margin: 0;
padding: 20px;
}
.container {
max-width: 600px;
margin: 30px auto;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
label {
display: block;
margin: 15px 0 5px;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
font-size: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
display: block;
width: 100%;
padding: 12px;
font-size: 1rem;
background: #007bff;
color: #fff;
border: none;
border-radius: 4px;
margin-top: 20px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
#log {
margin-top: 20px;
padding: 15px;
background: #e9ecef;
border-radius: 4px;
min-height: 150px;
white-space: pre-wrap;
font-family: monospace;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Token Rug Rate Analyzer</h1>
<label for="tokenAddress">Token Contract Address:</label>
<input type="text" id="tokenAddress" placeholder="0x..." />
<label for="walletAddress">Deployer Wallet Address:</label>
<input type="text" id="walletAddress" placeholder="0x..." />
<button id="analyzeBtn">Run Analysis</button>
<div id="log"></div>
</div>
<!-- Load ethers.js from CDN -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethers.umd.min.js"></script>
<script>
const logArea = document.getElementById("log");
// Helper function to log messages to the log area
function log(message) {
logArea.textContent += message + "\n";
}
// Main analysis function
async function analyzeWalletRugRate(tokenAddress, deployerAddress) {
// Replace with your actual Base network RPC URL
const provider = new ethers.providers.JsonRpcProvider(
"https://base-mainnet.g.alchemy.com/v2/WWKPM2lGz7XNIPROAhmfR8VMhBbmSOp7"
);
// Minimal ERC-20 ABI with totalSupply, balanceOf, and the Transfer event
const tokenABI = [
"function totalSupply() view returns (uint256)",
"function balanceOf(address owner) view returns (uint256)",
"event Transfer(address indexed from, address indexed to, uint256 value)",
];
const tokenContract = new ethers.Contract(
tokenAddress,
tokenABI,
provider
);
try {
log("Fetching total token supply...");
const totalSupply = await tokenContract.totalSupply();
log("Total Token Supply: " + totalSupply.toString());
} catch (error) {
log("Error fetching total supply: " + error);
return;
}
try {
log("Querying Transfer events for deployer...");
const filter = tokenContract.filters.Transfer(deployerAddress, null);
// Query events from block 0 to the latest block
const events = await tokenContract.queryFilter(filter, 0, "latest");
let soldAmount = ethers.BigNumber.from(0);
events.forEach((event) => {
soldAmount = soldAmount.add(event.args.value);
});
log("Sold Tokens: " + soldAmount.toString());
log("Fetching current balance for deployer...");
const currentBalance = await tokenContract.balanceOf(deployerAddress);
log("Current Balance: " + currentBalance.toString());
const initialAllocation = currentBalance.add(soldAmount);
log("Initial Allocation: " + initialAllocation.toString());
let rugRate = 0;
if (!initialAllocation.isZero()) {
rugRate = soldAmount.mul(100).div(initialAllocation).toNumber();
}
log("Rug Rate (%): " + rugRate);
} catch (error) {
log("Error during analysis: " + error);
}
}
// Button click event to start the analysis
document
.getElementById("analyzeBtn")
.addEventListener("click", async () => {
// Clear previous log messages
logArea.textContent = "";
const tokenAddress = document
.getElementById("tokenAddress")
.value.trim();
const walletAddress = document
.getElementById("walletAddress")
.value.trim();
if (!tokenAddress || !walletAddress) {
log(
"Please enter both the token contract address and the deployer wallet address."
);
return;
}
log("Starting analysis...");
await analyzeWalletRugRate(tokenAddress, walletAddress);
log("Analysis complete.");
});
</script>
</body>
</html>