0

Hi I am trying to get all transfer from USDT Token of 1 Token holder with the following information:

  • token contract: 0xdAC17F958D2ee523a2206206994597C13D831ec7
  • token holder: 0x28C6c06298d514Db089934071355E5743bf21d60

Here is the link to that transfer: https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7?a=0x28c6c06298d514db089934071355e5743bf21d60

`from web3 import Web3, HTTPProvider

instantiate a web3 remote provider

w3 = Web3(HTTPProvider('https://ethereum-mainnet.s.chainbase.online ...'))

Tether (USDT) token contract address

token_contract_address = "0xdAC17F958D2ee523a2206206994597C13D831ec7"

Replace with the token holder address you want to query

token_holder_address = "0x28C6c06298d514Db089934071355E5743bf21d60"

from web3 import eth_abi

def get_transactions_with_token(web3, token_contract_address, token_holder_address): contract = web3.eth.contract(address=token_contract_address, abi=ERC20_ABI)

transfer_topic = web3.keccak(text="Transfer(address,address,uint256)")

transfer_events = web3.eth.getLogs({
    "address": token_contract_address,
    "topics": [transfer_topic, None, token_holder_address],
    "fromBlock": 0,
    "toBlock": "latest",
    
})

transactions = []
for event in transfer_events:
    decoded_event = eth_abi.decode_log(contract.abi, event.data, event.topics)
    tx_hash = event.transactionHash.hex()
    quantity = decoded_event[2]
    transactions.append({"tx_hash": tx_hash, "quantity": quantity})

return transactions

Replace ERC20_ABI with the ABI (Application Binary Interface) of the ERC-20 token contract.

You can obtain the ABI from the token contract's official documentation or an Ethereum block explorer.

ERC20_ABI = [{"constant":True,"inputs":[],"name":"name","outputs":[{"name":"","type":"stri"type":"event"}] # Replace with the actual ABI

Call the function to get the transactions with the specified token contract and token holder

transactions = get_transactions_with_token(w3, token_contract_address, token_holder_address) print(transactions)`

but i can't get transfer info like in this picture enter image description here

0 Answers0