-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiwallet.py
280 lines (228 loc) · 9.74 KB
/
multiwallet.py
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import requests
import time
import os
from config import BUY_AMOUNT, RPC, PRIV_KEY
from pump_fun import buy_spamtx, sell_spamtx
import time
from colored import Fore, Back, Style
import random
from solders.keypair import Keypair
from solana.rpc.api import Client
from spl.token.instructions import create_associated_token_account, get_associated_token_address
from solana.rpc.types import TokenAccountOpts
from spl.token.client import Token
from solders.pubkey import Pubkey #type: ignore
import threading
bought_tokens = []
client = Client(RPC)
def get_new_tokens():
endpoint_new_tokens = "https://client-api-2-74b1891ee9f9.herokuapp.com/coins?offset=0&limit=20&sort=created_timestamp&order=DESC&includeNsfw=true"
endpoint_trades = "https://client-api-2-74b1891ee9f9.herokuapp.com/trades/%mint%?limit=20&offset=0"
r = requests.get(url=endpoint_new_tokens)
data = r.json()
for coin in data:
timestamp = coin["created_timestamp"]
new_token = coin["mint"]
website = coin["website"]
telegram = coin["telegram"]
twitter = coin["twitter"]
curr_timestamp = round(time.time() * 1000)
if curr_timestamp - timestamp <= 8 * 1000 and telegram != None:
return new_token
return ""
def shouldSell(token_address):
endpoint_trades = f"https://client-api-2-74b1891ee9f9.herokuapp.com/trades/{token_address}?limit=2&offset=0"
trades_info = requests.get(endpoint_trades).json()
for trade in trades_info:
if trade["is_buy"] == False:
return True
return False
#####
#####
def find_data(data, field):
if isinstance(data, dict):
if field in data:
return data[field]
else:
for value in data.values():
result = find_data(value, field)
if result is not None:
return result
elif isinstance(data, list):
for item in data:
result = find_data(item, field)
if result is not None:
return result
return None
def get_token_balance(base_mint: str, pub_key):
try:
headers = {"accept": "application/json", "content-type": "application/json"}
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "getTokenAccountsByOwner",
"params": [
str(pub_key),
{"mint": str(base_mint)},
{"encoding": "jsonParsed"},
],
}
response = requests.post(RPC, json=payload, headers=headers)
ui_amount = find_data(response.json(), "uiAmount")
return float(ui_amount)
except Exception as e:
return None
def withdrawTokens_thread(token, dest_address, pub_address, payer_keypair):
try:
account_data = client.get_token_accounts_by_owner(pub_address, TokenAccountOpts(token))
source_token_account = account_data.value[0].pubkey
source_token_account_instructions = None
except:
source_token_account = get_associated_token_address(pub_address, token)
source_token_account_instructions = create_associated_token_account(pub_address, pub_address, token)
try:
account_data = client.get_token_accounts_by_owner(dest_address, TokenAccountOpts(token))
dest_token_account = account_data.value[0].pubkey
dest_token_account_instructions = None
except:
dest_token_account = get_associated_token_address(dest_address, token)
dest_token_account_instructions = create_associated_token_account(pub_address, dest_address, token)
transaction_finalized = False
while transaction_finalized == False:
token_balance = get_token_balance(token, pub_address)
if token_balance != None and token_balance >= 0.001:
try:
spl_client = Token(conn=client, pubkey=token, program_id=Pubkey.from_string("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), payer=payer_keypair)
transaction = spl_client.transfer(source=source_token_account, dest=dest_token_account, owner=payer_keypair, amount=int(float(token_balance)*1000000), multi_signers=None, opts=None, recent_blockhash=None)
tx_sign = transaction.value
time.sleep(20)
tx_status = client.get_signature_statuses([tx_sign]).value[0].confirmation_status
if "finalized" in str(tx_status).lower():
transaction_finalized = True
print(f"{Fore.green}[!] Succesfully sent " + str(token_balance) +" from " + str(pub_address))
return
else:
print(f"{Fore.yellow}[x] Transfer failed " + str(token_balance) +" from " + str(pub_address))
except Exception as e:
pass
else:
return
else:
return
def withdrawTokens(token, dest_address):
pks = []
with open("data/pks.txt", "r", encoding="utf-8") as f:
read_pks = f.read().split("\n")
for pk in read_pks:
pk = pk.replace("\n", "").replace(" ", "").replace("\r", "").strip()
if len(pk) > 5:
pks.append(pk)
os.system("cls")
print(f"\t{Fore.white}{Back.magenta} --- Withdraw Tokens ---\n")
print(f"{Style.reset}", end="")
threads = []
for pk in pks:
payer_keypair = Keypair.from_base58_string(pk)
pub_address = payer_keypair.pubkey()
t = threading.Thread(target=withdrawTokens_thread, args=(token, dest_address, pub_address, payer_keypair))
t.start()
threads.append(t)
for t in threads:
t.join()
print(f"{Style.reset}\nAll tokens have been transfered.\nPress [ENTER] to return")
input()
def printBalance():
pks = []
with open("data/pks.txt", "r", encoding="utf-8") as f:
read_pks = f.read().split("\n")
for pk in read_pks:
pk = pk.replace("\n", "").replace(" ", "").replace("\r", "").strip()
if len(pk) > 5:
pks.append(pk)
total_balance = 0.0
os.system("cls")
print(f"\t{Fore.white}{Back.green} --- SOL Balance ---\n")
print(f"{Style.reset}", end="")
for pk in pks:
payer_keypair = Keypair.from_base58_string(pk)
pub_address = payer_keypair.pubkey()
balance = client.get_balance(pub_address).value / 1000000000
print(str(pub_address) + "\t" + str(balance) + " SOL")
total_balance += balance
print("\nTotal Balance: " + str(total_balance) + " SOL\nPress [ENTER] to return")
input()
def spamTxBuy(token):
BUMP = True
pks = []
with open("data/pks.txt", "r", encoding="utf-8") as f:
read_pks = f.read().split("\n")
for pk in read_pks:
pk = pk.replace("\n", "").replace(" ", "").replace("\r", "").strip()
if len(pk) > 5:
pks.append(pk)
os.system("cls")
print(f"\t{Fore.white}{Back.green} --- TX Spammer ---\n")
print(f"{Style.reset}", end="")
while len(pks) >= 1:
wallet_pk = random.choice(pks)
payer_keypair = Keypair.from_base58_string(wallet_pk)
balance = client.get_balance(payer_keypair.pubkey()).value / 1000000000
if BUMP == True:
buy_amount = random.uniform(0.011, 0.018)
elif balance > 1.1:
buy_amount = 1.0
elif balance >= 0.02:
buy_amount = random.uniform(0.0101, 0.02)
else:
buy_amount = balance - 0.005
pks.remove(wallet_pk)
t = threading.Thread(target=buy_spamtx, args=(payer_keypair, token, buy_amount, 20))
t.start()
time.sleep(random.uniform(1, 2))
print("\nDone! Press [ENTER] to return")
input()
def spamTxSell(token):
pks = []
with open("data/pks.txt", "r", encoding="utf-8") as f:
read_pks = f.read().split("\n")
for pk in read_pks:
pk = pk.replace("\n", "").replace(" ", "").replace("\r", "").strip()
if len(pk) > 5:
pks.append(pk)
os.system("cls")
print(f"\t{Fore.white}{Back.green} --- TX Spammer ---\n")
print(f"{Style.reset}", end="")
while len(pks) >= 1:
wallet_pk = random.choice(pks)
payer_keypair = Keypair.from_base58_string(wallet_pk)
t = threading.Thread(target=sell_spamtx, args=(payer_keypair, token, 20))
t.start()
time.sleep(1)
#time.sleep(random.uniform(0.5, 3.5))
print("\nDone! Press [ENTER] to return")
input()
def main():
while True:
os.system("cls")
print(f"\t{Fore.white}{Back.cyan} --- Pump.Fun Tool ---\n")
print(f"{Style.reset}0. Print Address & Balance")
print(f"{Style.reset}1. Spam Buy TX")
print(f"{Style.reset}2. Spam Sell TX")
print(f"{Style.reset}3. Withdraw Tokens")
print(f"{Style.reset}\nChoose: ", end="")
choose = int(input().replace("\r", "").replace(" ", "").replace("\n", ""))
if choose == 1 or choose == 2 or choose == 3:
print(f"{Style.reset}Mint Address: ", end="")
token = str(input().replace("\r", "").replace(" ", "").replace("\n", ""))
if choose == 0:
printBalance()
elif choose == 1:
spamTxBuy(token)
elif choose == 2:
spamTxSell(token)
elif choose == 3:
print(f"{Style.reset}[-] Destination Address: ", end="")
dest_address = str(input().replace("\r", "").replace(" ", "").replace("\n", ""))
withdrawTokens(Pubkey.from_string(token), Pubkey.from_string(dest_address))
if __name__ == "__main__":
main()