67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
import os
|
|
import sys
|
|
import json
|
|
from web3 import Web3
|
|
|
|
# Manually load .env
|
|
env_vars = {}
|
|
try:
|
|
with open(".env", "r") as f:
|
|
for line in f:
|
|
if "=" in line and not line.startswith("#"):
|
|
key, value = line.strip().split("=", 1)
|
|
env_vars[key] = value
|
|
except FileNotFoundError:
|
|
print("Error: .env file not found")
|
|
sys.exit(1)
|
|
|
|
RPC_URL = env_vars.get("MAINNET_RPC_URL")
|
|
if not RPC_URL:
|
|
print("Error: MAINNET_RPC_URL not found in .env")
|
|
sys.exit(1)
|
|
|
|
w3 = Web3(Web3.HTTPProvider(RPC_URL))
|
|
if not w3.is_connected():
|
|
print("Error: Could not connect to RPC")
|
|
sys.exit(1)
|
|
|
|
# Transaction to check
|
|
tx_hash = "0x3006e75f8902e760917981ca3e1a6f332656d6a0b3fed96b45e2502f47e1db6a"
|
|
|
|
print(f"--- DIAGNOSING TRANSACTION: {tx_hash} ---")
|
|
|
|
try:
|
|
# 1. Check Receipt (Did it succeed?)
|
|
receipt = w3.eth.get_transaction_receipt(tx_hash)
|
|
status = "SUCCESS" if receipt.status == 1 else "FAILED"
|
|
print(f"Status: {status}")
|
|
|
|
if receipt.status == 1:
|
|
# 2. Get Transaction Details to find the sender
|
|
tx = w3.eth.get_transaction(tx_hash)
|
|
sender = tx['from']
|
|
value_eth = tx['value'] / 10**18
|
|
print(f"Sender: {sender}")
|
|
print(f"Value : {value_eth} ETH")
|
|
print(f"Block : {receipt.blockNumber}")
|
|
|
|
# 3. Check WETH Balance of the sender
|
|
WETH_ADDRESS = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
ERC20_ABI = json.loads('[{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"}]')
|
|
weth_contract = w3.eth.contract(address=WETH_ADDRESS, abi=ERC20_ABI)
|
|
|
|
weth_bal_wei = weth_contract.functions.balanceOf(sender).call()
|
|
weth_bal = weth_bal_wei / 10**18
|
|
|
|
print(f"\n--- FUNDS LOCATOR ---")
|
|
print(f"Your WETH Balance: {weth_bal} WETH")
|
|
|
|
if weth_bal >= value_eth:
|
|
print(f"✅ GOOD NEWS: The funds are in your wallet as WETH (Wrapped ETH).")
|
|
print(f" You may need to 'Import Token' {WETH_ADDRESS} in your wallet to see them.")
|
|
else:
|
|
print(f"⚠️ Odd. Balance ({weth_bal}) is less than transaction value.")
|
|
|
|
except Exception as e:
|
|
print(f"Error checking transaction: {e}")
|