Hello, I’m trying to build BSC Wallet tracker in Python and I want to get all transactions from Moralis API and here is my problem:
When I’m trying to get all transactions I only get first 500 tx’s and i dont know how to get all transactions i tried to play with “offset” and “limit” functions but i dont understand how… I mean i dont know what to put in offest or limit to get all transactions. here is my code:
import requests
import json
fee_used_as_sender = []
fee_used_as_sender.clear()
fee_used_as_reciver = []
fee_used_as_reciver.clear()
def fee_counter():
headers= {'x-api-key':'API KEY'}
wallet_address = 'BSC WALLET ADDRES HERE'
txs_url = 'https://deep-index.moralis.io/api/v2/' + wallet_address + '?chain=bsc'
response = requests.get(txs_url,headers=headers).text
txs = json.loads(response)
n = 0
while n < 500:
native_tx_result = txs['result'][n]
from_address = native_tx_result['from_address']
receipt_gas_used = native_tx_result['receipt_gas_used']
gas_price = native_tx_result['gas_price']
tx_hash = native_tx_result['hash']
gas_price = '{0:,.8f}'.format(float(float(gas_price) / 10 ** 18))
tx_fee = float(gas_price) * float(receipt_gas_used)
if from_address == wallet_address:
fee_used_as_sender.append(tx_fee)
n += 1
else:
fee_used_as_reciver.append(tx_fee)
n += 1
print("fee_used_as_sender: ", sum(fee_used_as_sender))
print("fee_spent_as_reciver: ", sum(fee_used_as_reciver))
fee_counter()
Thanks in Advance