I'm trying to get the txs associated with a smart contract to read tx by tx.
I only found one way to do it so far:
(web3.py)
first_block = 13123500
block = 13401564
all the blocks of the contract
while block > first_block:
print("Block: "+ str(block))
# JSON from current block
json_blocks = json.loads(Web3.toJSON(web3.eth.get_block(block)))
# iterate over transactions of current block
for x in json_blocks['transactions']:
try:
# JSON current tx
tx_info = json.loads(Web3.toJSON(web3.eth.get_transaction(x)))
# If tx is from our contract
if tx_info['to'] == keys.CONTRACT_ADDRESS:
#Do stuff
except:
print()
block -= 1
But this takes too long...
My question is: Any form to get all the tx from a smart contract without read block by block and later tx by tx?
There are 300.000 blocks to read...
Thanks in advance!
Iván M.M