Skip to content

Instantly share code, notes, and snippets.

@gdsoumya
Created November 21, 2020 18:12
Show Gist options
  • Save gdsoumya/28b6bc493baef94878125664ddd2e5c6 to your computer and use it in GitHub Desktop.
Save gdsoumya/28b6bc493baef94878125664ddd2e5c6 to your computer and use it in GitHub Desktop.
Tezos Transaction Monitor script using tzkt api
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