├── .env.example ├── .gitignore ├── README.md ├── alchemy_get_events.py ├── alchemy_get_transactions.py ├── brute_force.py ├── brute_force_events.py ├── get_event.sql ├── get_transactions.sql └── requirements.txt /.env.example: -------------------------------------------------------------------------------- 1 | RPC_URL=https://laksdflasjdfs.com 2 | ALCHEMY_API_KEY=asdfasdfs -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | venv -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Get all transactions from an address 2 | 3 | We look at some techniques to get all transactions from an address, as well as get certain events. You can read my full blog on this here. 4 | 5 | # Getting Started 6 | 7 | ## Requirements 8 | 9 | - [Python](https://www.python.org/downloads/) 3.7 or higher 10 | - You'll know you've done it right if you can run `python3 --version` in your terminal and see something like `Python 3.10.6` 11 | 12 | ## Installation 13 | 14 | ```bash 15 | git clone https://github.com/PatrickAlphaC/get-all-transactions 16 | cd get-all-transactions 17 | pip install -r requirements.txt 18 | ``` 19 | 20 | To use the `alchemy` prefixed scripts, you'll need to set the `ALCHEMY_API_KEY` environment variable to your Alchemy API key. 21 | 22 | For using any other python script, you'll need an `RPC_URL` environment variable set to your RPC URL. 23 | 24 | ## Use 25 | 26 | ``` 27 | python3 alchemy_get_events.py 28 | ``` 29 | 30 | Or call any other python script. Feel free to edit the scripts for your needs. 31 | -------------------------------------------------------------------------------- /alchemy_get_events.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from alchemy_sdk_py import Alchemy 4 | 5 | ALCHEMY_API_KEY = os.getenv("ALCHEMY_API_KEY") 6 | CHAIN_ID = 1 7 | MY_ADDRESS = "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" # Aave token on ETH Mainnet 8 | 9 | 10 | def main(): 11 | alchemy = Alchemy(network=CHAIN_ID) 12 | upgraded_events = alchemy.get_logs( 13 | contract_address=MY_ADDRESS, 14 | topics=["0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b"], 15 | ) 16 | print(upgraded_events) 17 | 18 | 19 | if __name__ == "__main__": 20 | main() 21 | -------------------------------------------------------------------------------- /alchemy_get_transactions.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from alchemy_sdk_py import Alchemy 4 | 5 | ALCHEMY_API_KEY = os.getenv("ALCHEMY_API_KEY") 6 | CHAIN_ID = 1 7 | MY_ADDRESS = "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" # Aave token on ETH Mainnet 8 | 9 | 10 | def main(): 11 | alchemy = Alchemy(network=CHAIN_ID) 12 | transfers = alchemy.get_asset_transfers(to_address=MY_ADDRESS) 13 | # this is a paginated version, we could add `get_all_flag=True` but we'd make a LOT of API calls! 14 | print(transfers) 15 | 16 | 17 | if __name__ == "__main__": 18 | main() 19 | -------------------------------------------------------------------------------- /brute_force.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from web3 import Web3 4 | 5 | START_BLOCK = 17950195 6 | END_BLOCK = 17950197 7 | 8 | MY_ADDRESS = "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" # Aave token on ETH Mainnet 9 | 10 | 11 | def main(): 12 | w3 = Web3(Web3.HTTPProvider(os.getenv("RPC_URL"))) 13 | for block in range(START_BLOCK, END_BLOCK): 14 | block = w3.eth.get_block(block, full_transactions=True) 15 | for transaction in block.transactions: 16 | if MY_ADDRESS in transaction["from"] or MY_ADDRESS in transaction["to"]: 17 | print(transaction) 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /brute_force_events.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from web3 import Web3 4 | 5 | START_BLOCK = 17950195 6 | END_BLOCK = 17950197 7 | 8 | MY_ADDRESS = "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" # Aave token on ETH Mainnet 9 | 10 | 11 | def main(): 12 | w3 = Web3(Web3.HTTPProvider(os.getenv("RPC_URL"))) 13 | for block in range(START_BLOCK, END_BLOCK): 14 | block = w3.eth.get_block(block, full_transactions=True) 15 | for transaction in block.transactions: 16 | if MY_ADDRESS in transaction["from"] or MY_ADDRESS in transaction["to"]: 17 | breakpoint() 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /get_event.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | * 3 | FROM ethereum.logs 4 | WHERE 5 | "contract_address" = 0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9 6 | AND topic0 = from_hex('bc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b') 7 | -------------------------------------------------------------------------------- /get_transactions.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | * 3 | FROM ethereum.traces 4 | WHERE 5 | "from" = 0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9 6 | or "to" = 0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9 -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.8.5 2 | aiosignal==1.3.1 3 | alchemy-sdk-py==0.2.0 4 | async-timeout==4.0.3 5 | attrs==23.1.0 6 | bitarray==2.8.1 7 | certifi==2023.7.22 8 | charset-normalizer==3.2.0 9 | cytoolz==0.12.2 10 | eth-abi==4.1.0 11 | eth-account==0.9.0 12 | eth-hash==0.5.2 13 | eth-keyfile==0.6.1 14 | eth-keys==0.4.0 15 | eth-rlp==0.3.0 16 | eth-typing==3.4.0 17 | eth-utils==2.2.0 18 | frozenlist==1.4.0 19 | hexbytes==0.3.1 20 | idna==3.4 21 | jsonschema==4.19.0 22 | jsonschema-specifications==2023.7.1 23 | lru-dict==1.2.0 24 | multidict==6.0.4 25 | parsimonious==0.9.0 26 | protobuf==4.24.1 27 | pycryptodome==3.18.0 28 | python-dotenv==1.0.0 29 | pyunormalize==15.0.0 30 | referencing==0.30.2 31 | regex==2023.8.8 32 | requests==2.31.0 33 | rlp==3.0.0 34 | rpds-py==0.9.2 35 | toolz==0.12.0 36 | typing_extensions==4.7.1 37 | urllib3==2.0.4 38 | web3==6.8.0 39 | websockets==11.0.3 40 | yarl==1.9.2 41 | --------------------------------------------------------------------------------