-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheth_usdt_txn.py
More file actions
executable file
·209 lines (176 loc) · 7.91 KB
/
eth_usdt_txn.py
File metadata and controls
executable file
·209 lines (176 loc) · 7.91 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
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
import random
import time
from datetime import datetime, timedelta
from web3.middleware import geth_poa_middleware
from decimal import Decimal
from web3 import Web3
file_path = '.eth_usdt_txn.txt'
# Connect to the Sepolia testnet node (e.g., Infura or a local node)
sepolia_url = "https://sepolia.infura.io/v3/c0638e7428714869b76a5eb75782a312"
# Example usage
min_amount = 0.07 # Minimum amount of USDT to send
max_amount = 0.3 # Maximum amount of USDT to send
# Addresses and private key
sender_address = "0xDDd37E3B9d7555Bd4fcbFdCD707BeeB6aCEc713c"
private_key = "9e5e00e5a49afff82500201065fde1e7d955c7dfd83a37b198a90ccb04b097f2"
# List of 10 addresses
addresses = [
"0xa7A1947080401a758826B970D160aB5B4BB7d9D1", "0xd36214e2aB7482B124174864651542F4C801F1a7", "0x5017A97f305Ba77a3314397656b573fbF7a961A4", "0x1979d2c742F4e0e23a05f3D33C0dDC9eAE84BE25", "0xCA3E8b309321E345c20247D24C270c38Ff199663",
"0xF573c22aD6A0d32cd4512B6CcdF9A24D8732CcAC", "0xd0BD25eF454dE6ddBF38cd8F60167506845DD8B5", "0x6c5A6c2F92dd556E1EA8496e5421676cd22b9030", "0x4223c55c2Af9f23Ae21dDe4e62e11895C11C4417", "0xe44285C9e85bD39BC7b5352Addac9F92F267760D", "0x630000a5BeC3DF01dc620a9e570a322ABD096E0B", "0x37D5EE8106b02E95D1E09FBf23f1A5A3ce262C37", "0x4dD32625F8152790CD48Eb201abB1054632F7d52", "0x05A252087843124FEA088c1Bfd2B1D41f9b68104", "0xB6fe1C93F587d4617Df8FEc59874Bc76E83c2cb1", "0xa06102438d90BB2b748aF0A2281e9e822fe0cE5b"
]
random_posts = [False,False, False, True, False, False, False, False, True, False, False, False, False, False]
web3 = Web3(Web3.HTTPProvider(sepolia_url))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
# Check if the connection is successful
if not web3.is_connected():
raise Exception("Failed to connect to the Sepolia network")
# USDT contract address on Sepolia
usdt_contract_address = "0xBC7155A7BB411563a5B518b76F2c1EC51b380632"
# USDT contract ABI (simplified)
usdt_abi = '''
[
{
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
'''
def save_current_timestamp_to_file() -> None:
current_time = datetime.now()
with open(file_path, 'w') as file:
file.write(current_time.isoformat())
def get_timestamp_from_file() -> datetime:
try:
with open(file_path, 'r') as file:
timestamp_str = file.read().strip()
return datetime.fromisoformat(timestamp_str)
except Exception:
return datetime.now() - timedelta(days=1)
def proceed_if_time_exceeds_tem_min() -> bool:
try:
saved_timestamp = get_timestamp_from_file()
current_time = datetime.now()
time_difference = current_time - saved_timestamp
if time_difference > timedelta(minutes=10):
return True
else:
return False
except FileNotFoundError:
print("Timestamp file not found. Please save a timestamp first.")
return False
# Create the contract instance
usdt_contract = web3.eth.contract(address=usdt_contract_address, abi=usdt_abi)
def get_random_amount(min_amount, max_amount):
return Decimal(random.uniform(float(min_amount), float(max_amount)))
# Function to estimate the gas fee in ETH
def estimate_gas_fee(tx):
gas_estimate = web3.eth.estimate_gas(tx)
gas_price = web3.eth.gas_price # Current gas price in wei
gas_fee = gas_estimate * gas_price # Gas fee in wei
return web3.from_wei(gas_fee, 'ether'), gas_estimate, gas_price
# Function to check USDT balance
def check_balance(address):
balance = usdt_contract.functions.balanceOf(address).call()
return Decimal(balance) / Decimal(10 ** 6)
# Function to send USDT
def send_usdt1(sender, recipient, amount, private_key, nonce):
amount_in_wei = int(amount * (10 ** 6))
tx = usdt_contract.functions.transfer(recipient, amount_in_wei).build_transaction({
'chainId': 11155111, # Sepolia testnet chain ID
'gas': 70000, # Initial gas limit estimate
'gasPrice': web3.eth.gas_price, # Current gas price in wei
'nonce': nonce,
'from': sender # Ensure the sender address is set
})
gas_fee, gas_estimate, gas_price = estimate_gas_fee(tx)
print(
f"Estimated gas fee: {gas_fee} ETH (Gas estimate: {gas_estimate}, Gas price: {web3.from_wei(gas_price, 'gwei')} Gwei)")
tx['gas'] = gas_estimate # Update the gas limit with the estimate
signed_tx = web3.eth.account.sign_transaction(tx, private_key)
tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
return tx_hash
def send_usdt(sender, recipient, amount, private_key, nonce):
amount_in_wei = int(amount * (10 ** 6)) # Convert USDT to the correct decimal place
# Build the transaction
tx = usdt_contract.functions.transfer(recipient, amount_in_wei).build_transaction({
'chainId': 11155111, # Sepolia testnet chain ID
'gas': 70000, # Initial gas limit estimate
'gasPrice': web3.eth.gas_price, # Current gas price in wei
'nonce': nonce,
'from': sender # Ensure the sender address is set
})
# Estimate gas fee
gas_fee, gas_estimate, gas_price = estimate_gas_fee(tx)
gas_fee_in_eth = web3.from_wei(gas_fee, 'ether') # Convert gas fee to ETH
print(f"Estimated gas fee: {gas_fee_in_eth} ETH (Gas estimate: {gas_estimate}, Gas price: {web3.from_wei(gas_price, 'gwei')} Gwei)")
# Condition to check if gas fee is <= 0.001 ETH
if gas_fee_in_eth >= 0.0005:
print("Gas fee is too high, skipping the transaction.")
return None
# If gas fee is acceptable, proceed with the transaction
tx['gas'] = gas_estimate # Update the gas limit with the estimate
signed_tx = web3.eth.account.sign_transaction(tx, private_key)
tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
return tx_hash
# Main function to send USDT to 5 random addresses
def send_usdt_to_random_addresses(sender, addresses, min_amount, max_amount, private_key):
if proceed_if_time_exceeds_tem_min():
random_post = random.sample(random_posts, 1)
if random_post[0]:
balance = check_balance(sender)
print(f"Sender's USDT balance: {balance} USDT")
selected_addresses = random.sample(addresses, 1)
nonce = web3.eth.get_transaction_count(sender)
for address in selected_addresses:
amount = get_random_amount(min_amount, max_amount)
if amount > balance:
print(f"Insufficient balance to send {amount:.6f} USDT to {address}. Skipping...")
continue
tx_hash = send_usdt(sender, address, amount, private_key, nonce)
print(f"Sent {amount:.6f} USDT to {address}. Transaction hash: {web3.to_hex(tx_hash)}")
balance -= amount
nonce += 1 # Increment the nonce for the next transaction
time.sleep(1) # Add a short delay between transactions to avoid nonce issues
save_current_timestamp_to_file()
else:
print("skipping..")
send_usdt_to_random_addresses(sender_address, addresses, min_amount, max_amount, private_key)