def main(indexer_token, indexer_URL, manifestPath, outputXesPath): theIndexer = indexer.IndexerClient(indexer_token, indexer_URL, headers={'User-Agent': '?'}) extract(theIndexer, manifestPath, outputXesPath) sys.exit(0)
def indexer(): myindexer = indexer.IndexerClient(indexer_token="", indexer_address="http://localhost:8980") response = myindexer.search_transactions(min_amount=10, limit=5) # Pretty Printing JSON string print(json.dumps(response, indent=2, sort_keys=True)) # /indexer/python/search_transactions_paging.py nexttoken = "" numtx = 1 # loop using next_page to paginate until there are no more transactions in the response # for the limit (max is 1000 per request) while (numtx > 0): response = myindexer.search_transactions(min_amount=100000000000000, limit=2, next_page=nexttoken) transactions = response['transactions'] numtx = len(transactions) if (numtx > 0): nexttoken = response['next-token'] # Pretty Printing JSON string print("Tranastion Info: " + json.dumps(response, indent=2, sort_keys=True))
def __init__(self): headers = { "X-API-Key": "zLAOcinLq31BhPezSnHQL3NF7qBwHtku6XwN8igq", } self.myindexer = indexer.IndexerClient( "", "https://testnet-algorand.api.purestake.io/idx2", headers) self.savedHashes = [] self.getHashValues()
def configIndexer(): print("## START Indexer configuration ##\n") # instantiate indexer client myIndexer = indexer.IndexerClient(indexer_token="", indexer_address="http://localhost:8980") print("# END Indexer configuration #\n") return myIndexer
def connect_to_algo(connection_type=''): #Connect to Algorand node maintained by PureStake algod_token = "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab" headers = {"X-API-Key": algod_token} if connection_type == "indexer": # TODO: return an instance of the v2client indexer. This is used for checking payments for tx_id's algod_address = "https://testnet-algorand.api.purestake.io/idx2" ind = indexer.IndexerClient(indexer_token=algod_token, indexer_address=algod_address) return ind else: # TODO: return an instance of the client for sending transactions # Tutorial Link: https://developer.algorand.org/tutorials/creating-python-transaction-purestake-api/ algod_address = "https://testnet-algorand.api.purestake.io/ps2" acl = algod.AlgodClient(algod_token, algod_address, headers) return acl return None
import os from algosdk import account, mnemonic from algosdk.future.transaction import PaymentTxn from algosdk.v2client import indexer, algod import models # Set Configuration Values ALGOD_ADDRESS = os.getenv('ALGOD_ADDRESS', 'Token Not found') INDEXER_ADDRESS = os.getenv('INDEXER_ADDRESS', 'Token Not found') API_KEY = os.getenv('API_KEY', 'Token Not found') HEADERS = {"x-api-key": API_KEY} ALGODCLIENT = algod.AlgodClient(algod_token=API_KEY, algod_address=ALGOD_ADDRESS, headers=HEADERS) myindexer = indexer.IndexerClient(indexer_token=API_KEY, indexer_address=INDEXER_ADDRESS, headers=HEADERS) def get_balance(username): address = models.fetch_user(username)[0][1] response = myindexer.account_info(address=address) if 'account' in response: balance = float(response['account']['amount']) / 1000000 else: balance = 0 return balance def algo_transaction(sender, private_key, receiver, amount): """Function for Algos transfer"""
# INDEXER_TOKEN = "a" * 64 ALGOD_ADDRESS = "https://testnet-algorand.api.purestake.io/ps2" ALGOD_TOKEN = "mpgzbZLnJO77lSSIgfmC6WBF0H6goHg7KXw6noo6" INDEXER_ADDRESS = "https://testnet-algorand.api.purestake.io/idx2" INDEXER_TOKEN = ALGOD_TOKEN # ...hold your horses, I have registered a temporary account for this demo _only_ 🐎 # Some services (e.g. Purestake) require additional headers. ALGOD_HEADERS = { "X-API-Key": ALGOD_TOKEN, } INDEXER_HEADERS = { "X-API-Key": INDEXER_TOKEN, } algod_client = algod.AlgodClient( algod_token=ALGOD_TOKEN, algod_address=ALGOD_ADDRESS, headers=ALGOD_HEADERS ) indexer_client = indexer.IndexerClient( indexer_token=INDEXER_TOKEN, indexer_address=INDEXER_ADDRESS, headers=INDEXER_HEADERS, ) if __name__ == "__main__": print(algod_client.health()) # Returns None if the node is running, ¯\_(ツ)_/¯ print(indexer_client.health()) __import__('pprint').pprint(algod_client.status())
import json from algosdk.v2client import indexer algod_address = "https://testnet-algorand.api.purestake.io/idx2" algod_token = "" headers = { "X-API-Key": "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab", } indexer_client = indexer.IndexerClient(algod_token, algod_address, headers) name = 'test' limit = 1 response = indexer_client.search_assets(name=name, limit=limit) print("Asset search: " + json.dumps(response, indent=2, sort_keys=True))
def __init__(self): self.indexer_token = "xtWCVCYvt85bN4eqw87e02u4XsYDKdWK8KKJHQ3I" self.myindexer = indexer.IndexerClient(indexer_token=self.indexer_token, indexer_address='https://testnet-algorand.api.purestake.io/idx2')
def make_indexer_client(self, token: Optional[str] = None): if token is None: token = "" env = self._get_env() return indexer.IndexerClient(token, env.indexer_address)
from algosdk.v2client import indexer # instantiate indexer client # myindexer_token = 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab' # myindexer_address = 'https://betanet-algorand.api.purestake.io/idx2/' # myindexer_header = {'X-Api-key': myindexer_token} myindexer_token = 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab' myindexer_address = 'https://testnet-algorand.api.purestake.io/idx2/' myindexer_header = {'X-Api-key': myindexer_token} # myindexer_token = 'YddOUGbAjHLr1uPZtZwHOvMDmXvR1Zvw1f3Roj2PT1ufenXbNyIxIz0IeznrLbDsF' # myindexer_address = 'https://indexer-internal-betanet.aws.algodev.network:443' # myindexer_header = {'X-Indexer-API-Token': myindexer_token} # https://indexer-internal-beta//net.aws.algodev.network # myindexer = indexer.IndexerClient(indexer_token="", indexer_address="http://localhost:8980") # myindexer = indexer.IndexerClient( # indexer_token="", indexer_address=myindexer_address, headers=myindexer_header) myindexer = indexer.IndexerClient(indexer_token="", indexer_address=myindexer_address, headers=myindexer_header) # response = myindexer.accounts( # application_id=2672020) response = myindexer.accounts(application_id=12867764) print("Account Info: " + json.dumps(response, indent=2, sort_keys=True))
return txn def revokeDocument(pk, asset_id): txn = AssetConfigTxn(sender=pk, sp=params, index=asset_id, strict_empty_address_check=False) return txn from algosdk.v2client import indexer from base64 import b64decode from codecs import decode indexer_client = indexer.IndexerClient("", algod_address, headers) def verifyDocument(doc_name, owner_address, hashed_doc): response = indexer_client.search_assets(name=doc_name) print("ara") print("Asset search: " + json.dumps(response, indent=2, sort_keys=True)) #<<< FYI # I can check (1) existence (2) uniqueness (3) authenticity (4) integrity # "assets": [], => non-existence doc_info = response["assets"] if len(doc_info) <= 0: print("This document does not exist!") # "deleted": false => existence elif doc_info[0]["deleted"] == "true":
# headers = { # "Authorization": "Bearer KegWFLYQnBNVeP4oHCX64dObBk8VemzYdNqsnAOIxYQ8aqJLQTYeVDQyZNnx1PZA" # } # myindexer = indexer.IndexerClient(indexer_token="", indexer_address="https://indexer-testnet-green.aws.algodev.network", headers=headers) # algod_address = "https://testnet-algorand.api.purestake.io/idx2" # algod_token = "" # headers = { # "X-API-Key": "WpYvadV1w53mSODr6Xrq77tw0ODcgHAx9iJBn5tb", # } # myindexer = indexer.IndexerClient( # algod_token, algod_address, headers) # myindexer = indexer.IndexerClient(indexer_token="", indexer_address="http://localhost:8981") # myindexer = indexer.IndexerClient(indexer_token="YddOUGbAjHLr1uPZtZwHOvMDmXvR1Zvw1f3Roj2PT1ufenXbNyIxIz0IeznrLbDsF", indexer_address="https://indexer-testnet.internal.aws.algodev.network") myindexer = indexer.IndexerClient(indexer_token="", indexer_address="https://testnet.algoexplorerapi.io/idx2/") import base64 # note_prefix = '{"firstName":"JohnChr"'.encode() note_prefix = 'JohnChr'.encode() print(base64.b64encode('JohnChr'.encode())) # print(base64.b64encode('{"firstName":"JohnChr"'.encode())) # note_prefix = 'Hello Rus'.encode() # 14,556,497 # response = myindexer.search_transactions( # note_prefix=note_prefix, min_round=14556000, address="GD64YIY3TWGDMCNPP553DZPPR6LDUSFQOIJVFDPPXWEG3FVOJCCDBBHU5A") response = myindexer.search_transactions( note_prefix=note_prefix,min_round=14556000)
def main(): if len(sys.argv) == 1: # Display help if no arguments, see: # https://github.com/docopt/docopt/issues/420#issuecomment-405018014 sys.argv.append('--help') args = docopt(__doc__) print(title()) if args['poem']: return print(poem()) # Clients token = args['<purestake-api-token>'] header = {'X-Api-key': token} algod_client = algod.AlgodClient(algod_token=token, algod_address=ALGOD_ADDRESS, headers=header) indexer_client = indexer.IndexerClient(indexer_token=token, indexer_address=INDEXER_ADDRESS, headers=header) if args['verify-order']: summary = order_summary(algod_client, verify_buy_order(args['<seller-address>'])) return print(summary) if args['dynasty']: print(r""" *** DYNASTY *** """) return print(*['\n', *history(indexer_client)]) # Checking mnemonic format try: assert len(args['<mnemonic>'].split()) == 25 except AssertionError: quit('The mnemonic phrase must contain 25 words, ' 'formatted as: "word_1 word_2 ... word_25"\n') private_key = mnemonic.to_private_key(args['<mnemonic>']) user = Account(account.address_from_private_key(private_key), private_key) if args['claim-crown']: opt_in(algod_client, user, CROWN_ID) name = args['<majesty-name>'] claim_nft( algod_client=algod_client, indexer_client=indexer_client, claimer=user, claim_arg='Crown', new_majesty=name, donation_amount=int(args['<microalgos>']), nft_id=CROWN_ID, ) print(f"\n👑 Glory to {name}, the Randomic Majesty of Algorand! 🎉\n") elif args['claim-sceptre']: opt_in(algod_client, user, SCEPTRE_ID) name = args['<majesty-name>'] claim_nft( algod_client=algod_client, indexer_client=indexer_client, claimer=user, claim_arg='Sceptre', new_majesty=name, donation_amount=int(args['<microalgos>']), nft_id=SCEPTRE_ID, ) print(f"\n🪄 Glory to {name}, the Verifiable Majesty of Algorand! 🎉\n") elif args['claim-card']: if algod_client.status()["last-round"] <= ALGOREALM_CARD_FIRST_BLOCK: return print("🔐 The spell can be broken starting from the block " f"{ALGOREALM_CARD_FIRST_BLOCK}... ⏳\n") algorelm_card_contract = algod_client.account_info( CARD_CONTRACT.address) assets = algorelm_card_contract['assets'] card_nft = list( filter(lambda asset: asset['asset-id'] == CARD_ID, assets))[0] if card_nft['amount'] == 0: return print("🔓 The enchanted coffer is empty! " "The AlgoRealm Special Card has been claimed!\n") opt_in(algod_client, user, CARD_ID) print("\n✨ Whispering words of wisdom...") claim_card(algod_client=algod_client, claimer=user) print(f"\n 📜 The spell has been broken! " f"The AlgoRealm Special Card is yours! 🎉\n") if args['buy-order']: opt_in(algod_client, user, CARD_ID) amount = int(args['<microalgos>']) print( f"✏️ Placing order of: {util.microalgos_to_algos(amount)} ALGO\n") seller = Account(address=current_owner(indexer_client, CARD_ID), private_key='') trade_gtxn = card_order(algod_client=algod_client, buyer=user, seller=seller, price=amount) if args['--notify']: notify(algod_client, user, seller, trade_gtxn) return print( "\n📦 Send `trade.gtxn` file to the Seller to finalize the trade!\n" ) if args['sell-card']: sell_card(algod_client, user) else: quit("\nError: read AlgoRealm '--help'!\n")
import json from algosdk.v2client import indexer indexer_address = "https://testnet-algorand.api.purestake.io/idx2" indexer_token = "" headers = { "X-API-Key": "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab", } indexer_client = indexer.IndexerClient(indexer_token, indexer_address, headers) name = 'test' limit = 1 response = indexer_client.search_assets(name=name, limit=limit) print("Asset search: " + json.dumps(response, indent=2, sort_keys=True))
DEVELOPER_ACCOUNT_ADDRESS = account.address_from_private_key( DEVELOPER_ACCOUNT_PRIVATE_KEY) ESCROW_LOGICSIG = os.environ['ESCROW_LOGICSIG'] ESCROW_ADDRESS = os.environ['ESCROW_ADDRESS'] VALIDATOR_INDEX = int(os.environ['VALIDATOR_INDEX']) MANAGER_INDEX = int(os.environ['MANAGER_INDEX']) TOKEN1_INDEX = int(os.environ['TOKEN1_INDEX']) TOKEN2_INDEX = int(os.environ['TOKEN2_INDEX']) algod_client = algod.AlgodClient(ALGOD_TOKEN, ALGOD_ENDPOINT, headers={"x-api-key": ALGOD_TOKEN}) indexer_client = indexer.IndexerClient(INDEXER_TOKEN, INDEXER_ENDPOINT, headers={"x-api-key": INDEXER_TOKEN}) def wait_for_transaction(transaction_id): suggested_params = algod_client.suggested_params() algod_client.status_after_block(suggested_params.first + 4) result = indexer_client.search_transactions(txid=transaction_id) assert len(result['transactions']) == 1, result return result['transactions'][0] def withdraw_protocol_fees(): print("Building withdraw protocol fees atomic transaction group...") encoded_app_args = [bytes("p", "utf-8")]
# search_tx_address_block.py import json # requires Python SDK version 1.3 or higher from algosdk.v2client import indexer # instantiate indexer client myindexer = indexer.IndexerClient(indexer_token="", indexer_address="http://localhost:8980") response = myindexer.search_transactions_by_address( address="XIU7HGGAJ3QOTATPDSIIHPFVKMICXKHMOR2FJKHTVLII4FAOA3CYZQDLG4", block=7048877) print("block: 7048877 = " + json.dumps(response, indent=2, sort_keys=True))
import json # requires Python SDK version 1.3 or higher from algosdk.v2client import indexer # instantiate indexer client # myindexer_token = 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab' # myindexer_address = 'https://testnet-algorand.api.purestake.io/idx2/' # myindexer_header = {'X-Api-key': myindexer_token} myindexer_address = 'http://localhost:8981' indexer_token="" myindexer = indexer.IndexerClient( indexer_token, myindexer_address) # myindexer_address = "https://testnet-algorand.api.purestake.io/ps2" # myindexer_token = "" # headers = { # "X-API-Key": "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab", # } # myindexer = indexer.IndexerClient(myindexer_token, myindexer_address, headers=headers) # myindexer = indexer.IndexerClient( # indexer_token="", indexer_address=myindexer_address) nexttoken = "" num_accounts = 1 # loop using next_page to paginate until there are no more accounts # in the response # (max is 100 default # unless limit is used for max 1000 per request on accounts) while (num_accounts > 0):