Created
November 21, 2020 18:12
-
-
Save gdsoumya/28b6bc493baef94878125664ddd2e5c6 to your computer and use it in GitHub Desktop.
Tezos Transaction Monitor script using tzkt api
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
import time | |
import requests | |
baseURL = "https://api.carthage.tzkt.io/v1/operations/transactions/" | |
monitorList = ["opLak8mEJFE7QaqetLKFeV5z4CkjLH9jVMmLd9ihDViR4Ns5eFM", "onnFEco1CKasr1wCL8pw2r4Pv67kwt1tXd5pcRJc1HgLKjkZcdd", | |
"ootWDyBFeUAkEnKrD6uJSoP3MeN97i7zQgxoJbNwgQCQtkJk372", "oopn3M9UKZkrcxby8n2MmzWbCAb8FZBPE75ZZGeWoRix3CfUE2z"] | |
includedList = [] | |
# returns tx status : pending, applied, failed, backtracked, skipped | |
def getTxStatus(hash): | |
res = requests.get(baseURL+hash) | |
if res.status_code != 200: | |
raise Exception("STATUS : "+str(res.status_code)+" ERROR: "+res.text) | |
data = res.json() | |
if len(data) == 0: | |
return "pending" | |
return data[0]["status"] | |
def monitorTx(sleepTime): | |
while len(monitorList) != 0: | |
print("checking txs") | |
for tx in monitorList: | |
if getTxStatus(tx) != "pending": | |
includedList.append(tx) | |
monitorList.remove(tx) | |
print(monitorList, includedList) | |
time.sleep(sleepTime) | |
monitorTx(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment