Peera.

Post

Share your knowledge.

Expert Q&A

How do I get all incoming txs to an Eth address with a python script using Alchemy SDK?

I have an Alchemy API python script that checks the balance for an Ethereum address. According to the python alchemy-sdk docs, you can set up the Alchemy API object like this:

from alchemy import Alchemy, Network

# create Alchemy object using your Alchemy api key, default is "demo"
api_key = "your_api_key"

# choose preferred network from Network, default is ETH_MAINNET
network = Network.ETH_MAINNET

# choose the maximum number of retries to perform, default is 5
max_retries = 3

# create Alchemy object
alchemy = Alchemy(api_key, network, max_retries=max_retries)

From here you can get the ether balance of an address like this:

eth_address_balance = alchemy.core.get_balance("ADDRESS", "BLOCK_NUMBER")

Notice that you can get the address balance at any block height by adding "BLOCK_NUMBER" to the get_balance function.

How would I get all transactions that send ether to a certain address between 2 block heights?

I know your first instinct is to tell me to check Etherscan but I've noticed that some exchanges send ether to my address and no transaction appears on Etherscan... That's why I'm trying to build this script.

  • blockchain
  • wallet
0
0
Share
Comments
.

Do you know the answer?

Please log in and share it.

Web3 (also known as Web 3.0) is an idea for a new iteration of the World Wide Web which incorporates concepts such as decentralization, blockchain technologies, and token-based economics.

142Posts198Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignMay
We use cookies to ensure you get the best experience on our website.
More info