import requests
from web3 import Web3
from eth_abi import decode
def get_transaction_input_data(tx_hash):
apikey = "xxx"
url = f"https://api.bscscan.com/api?module=proxy&action=eth_getTransactionByHash&txhash={tx_hash}&apikey={apikey}"
response = requests.get(url)
transaction = response.json().get('result', {})
return transaction.get('input', '')
input_data = get_transaction_input_data("0xcbf70aa81c21cff3ae91fc95e0ec5b473fbb4d046e898b02cf93830e98fdeb7e")
print(f"Input Data: {input_data}")
w3 = Web3(Web3.HTTPProvider('https://bsc-dataseed1.binance.org/'))
types = ['address[]', 'uint256[]']
decoded_data = decode(types, bytes.fromhex(input_data[2:]))
recipients = decoded_data[0]
amounts = decoded_data[1]
print("Recipients: ", recipients)
print("Amounts: ", amounts)
causes
File "D:\python\bsc\query.py", line 23, in <module>
decoded_data = decode(types, bytes.fromhex(input_data[2:]))
File "D:\python\bsc\venv\lib\site-packages\eth_abi\codec.py", line 161, in decode
return decoder(stream)
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 129, in __call__
return self.decode(stream)
File "D:\python\bsc\venv\lib\site-packages\eth_utils\functional.py", line 47, in inner
return callback(fn(*args, **kwargs))
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 175, in decode
yield decoder(stream)
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 129, in __call__
return self.decode(stream)
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 146, in decode
stream.push_frame(start_pos)
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 95, in push_frame
self.seek_in_frame(0)
File "D:\python\bsc\venv\lib\site-packages\eth_abi\decoding.py", line 84, in seek_in_frame
self.seek(self._total_offset + pos, *args, **kwargs)
OverflowError: Python int too large to convert to C ssize_t
You can see the input data at https://bscscan.com/tx/0xcbf70aa81c21cff3ae91fc95e0ec5b473fbb4d046e898b02cf93830e98fdeb7e in the more details section
any ideas what to do about this?
The input data is sent to a smart contract function to deliver an airdrop. The data contains the recipients addresses and the amount to be airdropped
I wrote this code to extract the data myself
the types are ['address[]', 'uint256[]'] these are a wallet address without the 0x and the amount of tokens