-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (37 loc) · 1.93 KB
/
main.py
File metadata and controls
55 lines (37 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# author: Bartlomiej "furas" Burek (https://blog.furas.pl)
# date: 2021.11.19
#
# title: I would like to get all transactions given an address
# url: https://stackoverflow.com/questions/70028880/i-would-like-to-get-all-transactions-given-an-address
# [I would like to get all transactions given an address](https://stackoverflow.com/questions/70028880/i-would-like-to-get-all-transactions-given-an-address)
# https://michaelhly.github.io/solana-py/api.html
# https://docs.solana.com/cluster/rpc-endpoints
from solana.rpc.api import Client
all_addresses = [
'2AQdpHJ2JpcEgPiATUXjQxA8QmafFegfQwSLWSprPicm',
'Vote111111111111111111111111111111111111111',
'fake address',
]
#endpoint = 'https://api.devnet.solana.com' # probably for `developing`
#endpoint = 'https://api.testnet.solana.com' # probably for `testing`
endpoint = 'https://api.mainnet-beta.solana.com'
#endpoint = 'https://solana-api.projectserum.com'
solana_client = Client(endpoint)
for address in all_addresses:
print('address:', address)
#result = solana_client.get_confirmed_signature_for_address2(address, limit=1)
result = solana_client.get_signatures_for_address(address, before='89Tv9s2uMGaoxB8ZF1LV9nGa72GQ9RbkeyCDvfPviWesZ6ajZBFeHsTPfgwjGEnH7mpZa7jQBXAqjAfMrPirHt2')
if 'result' in result:
print('len:', len(result['result']))
# `[:5]` to display only first 5 items
for number, item in enumerate(result['result'][:5], 1):
print(number, 'signature:', item['signature'])
# check if there is "4SNQ4h1vL9GkmSnojQsf8SZyFvQsaq62RCgops2UXFYag1Jc4MoWrjTg2ELwMqM1tQbn9qUcNc4tqX19EGHBqC5u"
for number, item in enumerate(result['result'], 1):
if item['signature'].startswith('4SNQ'):
print('found at', number, '>>>', item['signature'])
else:
# error
print(result)
print('---')
#solana_client.get_account_info(address)