Created
June 11, 2021 05:26
-
-
Save youngkiu/7ead246c66d1bb6ff189ef43f03d98cf to your computer and use it in GitHub Desktop.
View Transactions.Actions within the Nine Chronicles block
This file contains 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 requests | |
def get_block_actions(block_hash): | |
query = ''' | |
query($blockHash: ID) { | |
chainQuery { | |
blockQuery { | |
block(hash: $blockHash) { | |
transactions { | |
id | |
actions { | |
inspection | |
} | |
} | |
} | |
} | |
} | |
} | |
''' | |
variables = {'blockHash': block_hash} | |
response = requests.post('http://localhost:23061/graphql', | |
json={'query': query, 'variables': variables}) | |
results = response.json() | |
transactions = results['data']['chainQuery']['blockQuery']['block']['transactions'] | |
for transaction in transactions: | |
print('TxId:', transaction['id']) | |
for actions in transaction['actions']: | |
print('action:', actions['inspection']) | |
if __name__ == '__main__': | |
# http://explorer.libplanet.io/9c-main/block/?fb3cb4ab24f16f2be7cabc741c10552b24446ae2864b95517acdbca74b79bdc9 | |
_block_hash = 'fb3cb4ab24f16f2be7cabc741c10552b24446ae2864b95517acdbca74b79bdc9' | |
_tx_ids = get_block_actions(_block_hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment