forked from atmosfermuda/bot_send
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
99 lines (92 loc) · 2.79 KB
/
index.js
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
const { request } = require("undici");
const fs = require("fs");
const {
DirectSecp256k1HdWallet,
EncodeObject,
Registry,
} = require("@cosmjs/proto-signing");
const { stringToPath } = require("@cosmjs/crypto");
const {
SigningStargateClient,
StargateClient,
defaultRegistryTypes,
} = require("@cosmjs/stargate");
const registry = new Registry([...defaultRegistryTypes]);
const colors = require('colors');
const { config } = require('dotenv');
config();
const lcdEndpoint = process.env.LCD;
const rpcEndpoint = process.env.RPC;
const addressReceiver = process.env.RECIPIENT;
const minimumBalance = process.env.MINIMUMBALANCE;
const minimumSend = process.env.MINIMUMSEND;
var mnemonic = process.env.MNEMONICS.split(","),
i = -1;
(function f(){
i = (i + 1) % mnemonic.length;
trx(mnemonic[ i ]);
setTimeout(f, 10000);
})();
async function getBalanceFor(wallet) {
let rewards = await (
await request(
lcdEndpoint +
"/cosmos/bank/v1beta1/balances/" +
wallet +
"/by_denom?denom=udvpn",
{ method: "GET", maxRedirections: 10 }
)
).body.json();
let rewardNum = BigInt(rewards.balance.amount);
return rewardNum;
}
async function trx (mnemonic) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
prefix: "sent",});
const [addressWallet] = await wallet.getAccounts();
const client = await SigningStargateClient.connectWithSigner(
rpcEndpoint,
wallet,
{ registry: registry });
const fee = {
amount: [
{
denom: "udvpn",
amount: "9793",
},
],
gas: "97922",
};
console.log("Checking wallet", addressWallet.address.yellow);
let balance = await getBalanceFor(addressWallet.address);
let dvpn = (balance - BigInt(minimumBalance))/1000000n;
let totals = BigInt(minimumBalance) + BigInt(minimumSend);
if (balance >= totals) {
balance = balance - BigInt(minimumBalance);
try {
let tx = await client.signAndBroadcast(
addressWallet.address,
[
{
typeUrl:
"/cosmos.bank.v1beta1.MsgSend",
value: {
fromAddress: addressWallet.address,
toAddress: addressReceiver,
amount: [
{
denom: "udvpn",
amount: balance.toString(),
}
],
},
},
],
fee,"Send Using AtmosferMuda Bot Send" //Please don't delete MEMO 😊
);
console.log('\x1b[32m%s\x1b[0m', "Successfully sent " + dvpn + " DVPN to " + addressReceiver + "! TX id: " + tx.transactionHash);
} catch(error) {
console.error(error);
}
}
}