Skip to content

Instantly share code, notes, and snippets.

@youngkiu
Created June 11, 2021 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youngkiu/7ead246c66d1bb6ff189ef43f03d98cf to your computer and use it in GitHub Desktop.
Save youngkiu/7ead246c66d1bb6ff189ef43f03d98cf to your computer and use it in GitHub Desktop.
View Transactions.Actions within the Nine Chronicles block
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