0

I'm working on project for a crypto exchange I have geth on a server and I'm using python as a programing language to communicate with geth using web3 library What i want to do is:

1/In bitcoin there's an option called walletnotify that runs a script whenever you get new transaction that is related to your wallet, how a, I supposed to do that in Ethereum?

2/ When I tried to run a small script to loop a 600 Ethereum block and try to get a transaction of specific address it took like 8 minute to do som and it didn't return any results, this is the example: I did a deposit to my address A and I checked Ethereum scan platform transaction information, the transaction was on the block 779688, my geth node was on the current block 779999 so when I run the script I told it to loop from block 779300 to 779900, it took like 8 minutes and it didn't even return the transaction information although that address had a transaction that happened in between the given interval, while using api from Ethereum scan and going from 0 to 9999999 blocks took only 1 second with a results

is this because I'm running the light mode and they are running the full node?

is it because the light mode have to download again the blocks and full node already have the blocks?

this is the script

    for x in range(start, end):
    block = w3.eth.getBlock(x, True)
    for transaction in block.transactions:
        if transaction['to'] == address or transaction['from'] == address:
            with open("transactions.pkl", "wb") as f:
                hashStr = transaction['hash'].hex()
                tx_dictionary[hashStr] = transaction
                pickle.dump(tx_dictionary, f)
            f.close()
print(f"Finished searching blocks {start} through {end} and found {len(tx_dictionary)} transactions")

3/my last question is, when I generate 5 addresses using web3 python and I deposit some balance to these different addresses, is there a way to do batching transaction to move all the balance to a central address (using web3 python)?

1

1 Answer 1

0

In Ethereum, you need to check every transaction in each block to determine if it's related to a specific address in order to retrieve all transactions associated with that address. Moreover, if it's a token contract, you have to parse each transaction and analyze the logs provided by get_transaction_receipt to identify if it includes your specified address.

Third-party APIs typically achieve fast retrieval by pre-parsing all transactions and storing them in databases like Elastic Search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.