Hi all I am trying to pull all mining history from PoW Giver 1 and am running the following (python) code:

METHOD = 'getTransactions'
url = f'https://api.ton.sh/{METHOD}?address=Ef-kkdY_B7p-77TLn2hUhM6QidWrrsl8FYWCIvBMpZKprKDH&page=1'
headers = {"Content-Type": "application/json"}
response = requests.request("GET", url, headers=headers)
json_blob = json.loads(response.text)

However when I try and change the page number (i.e. 2, 3, etc.), I am still only getting recent 10 tx's from this week. Have read the docs but am not sure what I am missing. Can anyone point me in the right direction?

Apr 5, 2022, 11:34 PM
Ah seems logical time == blocks
Apr 5, 2022, 11:38 PM
Hey. Where did you find the page parameter?
Apr 6, 2022, 3:36 AM
Didn't see on docs so I improvised... doesn't seem to be working...
Trying to get all tx's for a given account. From what I can gather the best way to do this is to pull the most recent ones and then use set the earliest logical time to the latest logical time for the next batch... However this seems like a hacky way to do it.

Would you have any recommendations sir? Currently reading newer whitepaper from 2021 but no mention of logical timee
Apr 6, 2022, 3:41 AM
It's actually right in the documentation :)

The cursor is controlled by these two parameters.
Just get these two properties from the last transaction in a batch and query for the next one.
Apr 6, 2022, 3:46 AM
Ahh.
1) isn't hash unique to tx so couldn't be used to ID next?
2) i thought I could start at lt = 0 and work my way up but with API is limit is 10 so I wasn't sure how to get all tx's where they have the same lt but there are more than 10 of them
That led me to https://toncenter.com/api/v2/#/transactions/get_transactions_getTransactions_get
No limit (or seems to cover up to 1000 per request), more requests, and had to_lt field
Apr 6, 2022, 3:51 AM
The key point here as that you get recent results and scan to the past.
Apr 6, 2022, 3:51 AM
Yes but what if there are more than 10 tx's for a given lt?
Usually API has page and offset params to deal with this if limit is insufficient
Forgive me if I'm missing something here, currently making way through whitepaper
Apr 6, 2022, 3:52 AM
Address, LT and hash are three parameters that uniquely identify a transaction in TON. Essentially, you are using last received transaction as a cursor to get the next ones.
You should Google for cursor based pagination. Offset based pagination has its flaws.
Yes, TonCenter would be a more advanced solution. Be advised, that you will need to get the API token for it though.
Apr 6, 2022, 4:00 AM
Thank you - reading about it...
So is the most efficient way to start at lt = 0 and work way up to latest lt? (26864278000001)
Feel like 30 calls/min rate limit will make this slow and even if, I see a path to getting all tx's for a given lt, new request with latest tx_hash and lt as starting point.
Thank you - happy to pay for one but where can I get it? https://toncenter.com/ I messaged the bot to get one but no reply
Apr 6, 2022, 4:02 AM
I don't think that you will be able to start from LT = 0. You will start from recent transactions and will go to the past.
It's free and unlimited at the moment. However the limits will be implemented very soon.
Apr 6, 2022, 4:03 AM
Also, sir can I DM you or would you prefer to keep chat here? Don't want to clog up for others
I can see path to working forward but not backward... as tx and lt are where to start
Apr 6, 2022, 4:04 AM
However, you can install your own copy of TonCenter. It would be a better solution if you need to do historical scans.
The API will return the results in backward direction, starting from the most recent transactions and going into the past.
That's a little counter intuitive, but that's how it works.
Apr 6, 2022, 4:06 AM
I got you but if it goes backward and I can input lt and hash for starting points, one can guess the lt that comes before, but not the hash that comes before no?
Apr 6, 2022, 4:08 AM
By the way, I'm not sure if ton.sh will return you the entire history of transactions, it could be limited to more recent ones.
You don't guess it. You take these parameters from the last item in the batch.
Apr 6, 2022, 4:09 AM
Oooo
So even though the documentation says starting I can think of it like starting but facing in a backwards direction (i.e. starting newest --> oldest)? I am thinking of starting going forwards (i.e. oldest --> newest) and based off what your saying think have to shift paradigm
Apr 6, 2022, 4:11 AM
Yep, that's right.
That's what I've said above :)
Apr 6, 2022, 4:12 AM
Ah thank you... wanted to confirm
Appreciate you taking the time to explain it to me! 🙏
Apr 6, 2022, 4:12 AM
No problem, good luck )
If you would have any questions regarding TON development you can always ask here.
Apr 6, 2022, 4:13 AM
Will do! I am very much enjoying whitepaper - kudos to u and team for work you are doing and appreciate your responsiveness
GN
Apr 6, 2022, 4:14 AM
👍
Apr 6, 2022, 4:15 AM

© 2024 Draquery.com All rights reserved.