Created
February 2, 2025 21:57
-
-
Save sambacha/7829b14277cd2b7cfdbc480997a80b62 to your computer and use it in GitHub Desktop.
Find out Safe Wallet address Origin for Transaction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import json | |
import os | |
# Replace | |
# <$SAFE_WALLET_ADDRESS> | |
# With your address | |
# | |
# Example output: | |
# | |
# Processed page 1: Found 0 WalletConnect transactions (Total: 0) | |
# Processed page 2: Found 0 WalletConnect transactions (Total: 0) | |
# Processed page 3: Found 4 WalletConnect transactions (Total: 4) | |
# Processed page 4: Found 19 WalletConnect transactions (Total: 23) | |
# Processed page 5: Found 25 WalletConnect transactions (Total: 48) | |
# Processed page 6: Found 0 WalletConnect transactions (Total: 48) | |
# Processed page 7: Found 0 WalletConnect transactions (Total: 48) | |
# Processed page 8: Found 0 WalletConnect transactions (Total: 48) | |
# Processed page 9: Found 0 WalletConnect transactions (Total: 48) | |
# Processed page 10: Found 0 WalletConnect transactions (Total: 48) | |
# Processed page 11: Found 1 WalletConnect transactions (Total: 49) | |
# Processed page 12: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 13: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 14: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 15: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 16: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 17: Found 0 WalletConnect transactions (Total: 49) | |
# Processed page 18: Found 0 WalletConnect transactions (Total: 49) | |
# Saved 1767 transactions to walletconnect_transactions.json | |
# 49 WalletConnect transactions were made with this Safe | |
# | |
# | |
def main(): | |
# Define the URL and output file path | |
url = 'https://safe-transaction-mainnet.safe.global/api/v1/safes/<$SAFE_WALLET_ADDRESS>/multisig-transactions/' | |
output_file = 'walletconnect_transactions.json' | |
# Initialize counters | |
wc_tx_all = 0 | |
page_count = 0 | |
all_transactions = [] | |
# Fetch and process data | |
while True: | |
r = requests.get(url) | |
data = r.json() | |
page_count += 1 | |
# Filter and count WalletConnect transactions | |
wc_tx_page = len([x for x in data['results'] if x.get('origin') and "WalletConnect" in x['origin']]) | |
wc_tx_all += wc_tx_page | |
# Save the current page's transactions | |
all_transactions.extend(data['results']) | |
# Print progress | |
print(f'Processed page {page_count}: Found {wc_tx_page} WalletConnect transactions (Total: {wc_tx_all})') | |
# Break if there's no next page | |
if not data.get('next'): | |
break | |
# Update URL for the next page | |
url = data['next'] | |
# Save all transactions to disk | |
with open(output_file, 'w') as f: | |
json.dump(all_transactions, f, indent=2) | |
print(f'Saved {len(all_transactions)} transactions to {output_file}') | |
print(f'{wc_tx_all} WalletConnect transactions were made with this Safe') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment